By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

I have javascript code which run successfully on firefox but not on internet Explorer

P: 1
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. <script type="text/javascript">
  5. var element;
  6. function test(){  
  7.         abc = document.getElementById('promptbox').value;
  8.         document.forms['form0'].elements[element].value = abc; 
  9.         return true;
  10.  
  11. function prompt() {
  12.     el = document.getElementById("prompt");
  13.     el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
  14. }
  15.  
  16.         <!--
  17.         function callPrompt(elementID){
  18.             element = elementID;
  19.             prompt2('btn1p.gif', 'My Prompt','Please enter your information', 'myfunction');
  20.                         prompt();
  21.         }
  22.         //-->
  23.  
  24.         var response = null 
  25.  
  26.             function prompt2(promptpicture, prompttitle, message, sendto) {
  27.                 promptbox = document.createElement('div');
  28.                 promptbox.setAttribute ('id' , 'prompt') 
  29.                     document.getElementsByTagName('body')[0].appendChild(promptbox) 
  30.                     promptbox = eval("document.getElementById('prompt').style") 
  31.                     promptbox.position = 'fixed' 
  32.                     promptbox.top = '150px' 
  33.                     promptbox.left = 0 
  34.                     promptbox.border = 'outset 1 #bbbbbb'  
  35.  
  36.                     document.getElementById('prompt').innerHTML = document.getElementById('prompt').innerHTML + "<table cellspacing='0' cellpadding='5' border='5' width='400px' height='400px' class='promptbox' align='center' bgcolor='#ededed'><tr><td align='center'><table><tr><td><br>" + message + "</td></tr><tr><td align='center'><input type='text' value='' name='promptbox' id='promptbox' onblur='this.focus()' class='promptbox' align='center'></td></tr><tr><td align='right'><br><input type='button' class='prompt' value='OK' onMouseOver='this.style.border=\"1 outset #dddddd\"' onMouseOut='this.style.border=\"1 solid transparent\"' onClick='prompt();test();'> <input type='button' class='prompt' value='Cancel' onMouseOver='this.style.border=\"1 outset transparent\"' onMouseOut='this.style.border=\"1 solid transparent\"' onClick='" + sendto + "(\"\"); document.getElementsByTagName(\"body\")[0].removeChild(document.getElementById(\"prompt\"))'></td></tr></table></td></tr></table>" 
  37.  
  38.                     document.getElementById("promptbox").focus() 
  39.                 } 
  40.  
  41.         function myfunction(value) { 
  42.  
  43.             if(value.length<=0)
  44.                 return false;
  45.             else
  46.                 document.getElementById('output').innerHTML="<b>"+value+"</b>";
  47.         }
  48. </script>
  49.  
  50. <style type="text/css">
  51. #prompt {
  52.      visibility: hidden;
  53.      position: absolute;
  54.      left: 0px;
  55.      top: 0px;
  56.      width:100%;
  57.      height:100%;
  58.      text-align:center;
  59.      z-index: 100;
  60. }
  61.  
  62. #prompt div {
  63.      width:300px;
  64.      margin: 100px auto;
  65.      background-color: #fff;
  66.      border:1px solid #000;
  67.      padding:15px;
  68.      text-align:center;
  69. }
  70.  
  71. body {
  72.      height:100%;
  73.      margin:0;
  74.      padding:0;
  75. }
  76. </style>
  77.  
  78. </head> 
  79. <body>  
  80. <form name="form0"><br><br><br><br> 
  81. <table align="center" width="500"><tr><td>
  82. Click on a textbox and dialog will appear, The issue is I want each textbox individualized so when the dialog info is entered, its inputted into the correct textbox. I need the dialog to recognize which textbox was clicked thru iteration as there may be hundreds of textboxes.
  83. </td></tr></table>
  84.  
  85. <p align="center">
  86. input1 <input type="text" name="input" id="input1" size ="30" onClick="callPrompt(this.id);"><br><br>
  87. input2 <input type="text" name="input" id="input2" size ="30" onClick="callPrompt(this.id);"><br><br>
  88. input3 <input type="text" name="input" id="input3" size ="30" onClick="callPrompt(this.id);"><br>
  89. And so on.....<br><br></p>
  90.  
  91. <table align="center" width="500"><tr><td align="left">
  92. Example:<br>
  93. I click on textbox "input1".....dialog appears,<br>
  94. I enter "Hello World!".....Then click "Ok",<br>
  95. textbox "input1" is filled in with "Hello World!"<br>
  96. <br>
  97. I click on textbox "input2".....dialog appears,<br>
  98. I enter "Hello World again!".....Then click "Ok",<br>
  99. textbox "input2" is filled in with "Hello World again!"<br>
  100. <br>
  101. I click on textbox "input3".....dialog appears,<br>
  102. I enter "and again Hello World!".....Then click "Ok",<br>
  103. textbox "input3" is filled in with "and again Hello World!"<br>
  104. And so on.....
  105. </td></tr></table> 
  106. </form>
  107.  
  108. </body>
  109. </html>
Sep 23 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
What doesn't work? What exactly do you expect it to do and what happens instead?
Sep 23 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.