code_junkie

Why doesn't this JavaScript display a confirm box?

Nov 11th, 2011
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. function lastCheckInv() {
  2.  
  3. document.getElementById("ctl00$ContentPlaceHolderMain$INDet$txtInvNumber").style.background = "yellow";
  4. document.getElementById("ctl00$ContentPlaceHolderMain$INDet$txtInvNumber").focus();
  5. document.getElementById("ctl00_ContentPlaceHolderMain_INDet_AddCharges").style.background = "yellow";
  6. document.getElementById("ctl00_ContentPlaceHolderMain_INDet_lblFreight").style.background = "yellow";
  7. bRetVal = confirm("Are you sure the information associated with this invoice is correct?");
  8.  
  9. return bRetVal;
  10.  
  11. }
  12.  
  13. document.getElementById(<%= txtInvNumber.ClientID %>).style.background = "yellow"
  14.  
  15. <script language="javascript">
  16. function lastCheckInv() {
  17.  
  18. document.getElementById("test1").style.background = "yellow";
  19. document.getElementById("test1").focus();
  20. document.getElementById("test2").style.background = "yellow";
  21. document.getElementById("test3").style.background = "yellow";
  22. bRetVal = confirm("Are you sure?");
  23.  
  24. return bRetVal;
  25.  
  26. }
  27. </script>
  28.  
  29. <form method="get" onsubmit="return lastCheckInv();">
  30. <input id="test1" name="test1" value="Hello">
  31. <input id="test2" name="test2" value="Hi">
  32. <input id="test3" name="test3" value="Bye">
  33. <input type="submit" name="Save" value="Save">
  34. </form>
  35.  
  36. document.getElementById("ctl00_ContentPlaceHolderMain_INDet_lblFreight").style.background = "yellow";
  37.  
  38. var obj = document.getElementById("ctl00_ContentPlaceHolderMain_INDet_lblFreight");
  39.  
  40. if(obj)
  41. {
  42. obj.style.background = "yellow";
  43. }
  44.  
  45. function lastCheckInv() {
  46.  
  47. var myObjs,bRetVal;
  48.  
  49. myObjs=[
  50. "ctl00_ContentPlaceHolderMain_INDet_AddCharges",
  51. "ctl00_ContentPlaceHolderMain_INDet_lblFreight",
  52. "ctl00$ContentPlaceHolderMain$INDet$txtInvNumber"
  53. ];
  54.  
  55.  
  56. bRetVal = confirm("Are you sure the information associated with this invoice is correct?");
  57.  
  58. for (var i=0, j=myObjs.length, myElement; i<j; i++){
  59.  
  60. myElement=document.getElementById(myObjs[i]);
  61.  
  62. if (!myElement){
  63. // this element is missing
  64. continue;
  65. }
  66.  
  67. else {
  68.  
  69. // apply colour
  70. myElement.style.background = "yellow";
  71.  
  72. // focus the last object in the array
  73.  
  74. if (i == (j-1) ){
  75. myObj.focus();
  76. }
  77.  
  78.  
  79. }
  80.  
  81. }
  82.  
  83.  
  84. return bRetVal;
  85.  
  86. }
  87.  
  88. function lastCheckInv()
  89.  
  90. {
  91. document.getElementById("ctl00_ContentPlaceHolderMain_INDet_txtInvNumber").style.background = "yellow";
  92. document.getElementById("ctl00_ContentPlaceHolderMain_INDet_txtInvNumber").focus();
  93. document.getElementById("ctl00_ContentPlaceHolderMain_INDet_AddCharges").style.background = "yellow";
  94. document.getElementById("ctl00_ContentPlaceHolderMain_INDet_lblFreight").style.background = "yellow";
  95. return confirm("Are you sure the information associated with this invoice is correct?");
  96. }
Add Comment
Please, Sign In to add comment