internet explorer - JavaScript event doesn't work in IE 8 -


it seems ie8 ignores click event! should add new row when press "+" button , remove on "-". i'm new web development can't see others issues. test , works fine ie10, ie9 doesn't work ie8!!! me sort problem!

my html code:

<table id="sysaffectedtable2">     <thead>         <tr>             <th>#</th>             <th><span class="locationname">location name</span></th>             <th>subnet (optional)</th>             <th>add</th>             <th>delete</th>         </tr>     </thead>     <tbody>         <tr>             <td>1</td>             <td><input type="text" id="locationname1" value="" name="locationname1"/></td>             <td><input type="text" id="subnet1" value="" name="subnet1"/></td>             <td><input type="button" style="width: 40px" id="adddiskbutton2" value="  +  " onclick="insertrow2()"/></td>             <td><input type="button" style="width: 40px" id="deldiskbutton2" value="  -  " onclick="deleterow2(this)"/></td>             </tr>     </tbody>             </table>     

my javascript code:

<script type="text/javascript" language="javascript">     var maxrow2=1;       var table2 = document.getelementbyid('sysaffectedtable2'), tbody2 = table2             .getelementsbytagname('tbody')[0], clone2 = tbody2.rows[0]             .clonenode(true);      function deleterow2(el) {         var = el.parentnode.parentnode.rowindex;          if (i != 1) {             table2.deleterow(i);             while (table2.rows[i]) {                 updaterow2(table2.rows[i], i, false);                 i++;             }             maxrow2--;         } else if (i == 1) {             table2.deleterow(i + 1);             while (table2.rows[i + 1]) {                 updaterow2(table2.rows[i + 1], + 1, false);                 i++;             }             maxrow2--;         }     }      function insertrow2() {         if (maxrow2 < 32) {             var new_row = updaterow2(clone2.clonenode(true),                     ++tbody2.rows.length, true);             tbody2.appendchild(new_row);             maxrow2++;         }     }      function updaterow2(row2, a2, reset2) {         row2.cells[0].innerhtml = a2;          var inp1 = row2.cells[1].getelementsbytagname('input')[0];         var inp2 = row2.cells[2].getelementsbytagname('input')[0];          inp1.name = 'locationname' + a2;         inp1.id = 'locationname' + a2;         inp2.name = 'subnet' + a2;         inp2.id = 'subnet' + a2;          if (reset2) {             inp1.value = inp2.value = '';         }         return row2;     } </script> 

you can see in live here - http://jsfiddle.net/yhanj/1/

please me!

thanks in advance!

an error being encountered on line: ++tbody2.rows.length

apparently ie8's javascript engine treats differently other browsers, doesn't make sense able change length property number of rows of table in any browser. if wanted change number of rows in table, you'd inserting new dom element (which you're doing .appendchild() call).

change tbody2.rows.length + 1 instead of trying increment length property directly.

edit: indeed, if try increment length other browsers, statement appears ignored. ie8 throws exception instead of ignoring it.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -