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

Onclick not running on IE..Please someone help me..

P: 1
Below is my code. It not running on IE..You may copy and try this code..
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" >
  4. <title>Untitled Document</title></head>
  5. <script language="JavaScript" type="text/javascript">
  6. var i=1;
  7. function addRow()
  8. {
  9.       var tbl = document.getElementById('table1');
  10.       var lastRow = tbl.rows.length;
  11.       var i = lastRow - 1;
  12.       var row = tbl.insertRow(lastRow);
  13.  
  14.       var firstCell = row.insertCell(0);
  15.       var select = document.createElement('select'); 
  16.       select.name = 'name_' + i;
  17.       select.id = 'name_' + i ;
  18.       select.class = 'post';
  19.  
  20.   select.innerHTML = document.getElementById('name_0').innerHTML;
  21.  
  22.  
  23.             firstCell.appendChild(select);
  24.  
  25.  
  26.       var secondCell = row.insertCell(1);
  27.       var el2 = document.createElement('input');
  28.       el2.type = 'text';
  29.       el2.name = 'address_' + i;
  30.       el2.id = 'address_' + i;
  31.       el2.size = 20;
  32.       el2.maxlength = 20;
  33.       secondCell.appendChild(el2);
  34.  
  35.       var thirdCell = row.insertCell(2);
  36.       var el3 = document.createElement('input');
  37.       el3.type = 'text';
  38.       el3.name = 'contactNum_' + i;
  39.       el3.id = 'contactNum_' + i;
  40.       el3.size = 20;
  41.       el3.maxlength = 20;
  42.       thirdCell.appendChild(el3);
  43.      // alert(i);
  44.       i++;
  45.       frm.h.value=i;
  46.     //  alert(i);
  47. }
  48. </script>
  49.  
  50. <body>
  51. <?php
  52. mysql_connect("localhost", "root", '')or die(mysql_error());
  53. mysql_select_db("test") or die(mysql_error());
  54. $num =  $_POST['h'];
  55. for($i=0;$i<$num;$i++)
  56. {
  57.  
  58.         $name       = $_POST["name_$i"];
  59.         $address    = $_POST["address_$i"];
  60.         $contactNum = $_POST["contactNum_$i"];
  61.  
  62. mysql_query("INSERT INTO `company`(`name`, `add`, `contact`) Values('$name', '$address', '$contactNum')") or die(mysql_error());
  63. }
  64.  
  65. ?>
  66.  
  67.  
  68.  
  69. <form  method="post" name="frm" id="frm">
  70. <table width="40%" border="2" cellpadding="0" cellspacing="0" id="table1">
  71.   <tr>
  72.     <td><strong>Name</strong></td>
  73.     <td><strong>Address</strong> </td>
  74.     <td><strong>Contact Num</strong> </td>
  75.   </tr>
  76. <tr>
  77.     <td><select class="post" name="name_0" id="name_0" >
  78.                <option >Supervisor Negeri</option>
  79.             <option >Pegawai Daftar</option>
  80.             <option >Pegawai Semak</option>
  81.             <option >Pegawai Pengesyoran</option>
  82.             <option >Pegawai Semak HQ</option>
  83.             <option >Pegawai Pemantau</option>
  84.                  </select>
  85.  
  86.  
  87. </td>
  88.     <td><input name="address_0" type="text" id="address_0" size="20" maxlength="20" /></td>
  89.     <td><input name="contactNum_0" type="text" id="contactNum_0" size="20" maxlength="12" /></td>
  90. </tr>
  91. </table>
  92. <input type="button" value="Add" onclick="addRow();" />
  93. <input name="Submit" type="submit" value="Submit" />
  94. <label>
  95. <input name="h" type="hidden" id="h" value="0" />
  96. </label>
  97. </form>
  98. </body>
  99. </html>
Jul 29 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

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