我本来是写一个表格的动态增加和删除行,在谷歌浏览器上正常的代码,在IE8上面就要报错。调试之后我发现IE8这个虽然appendChild成功显示了,但是表格的行数还是没变,太奇怪了
<!DOCTYPE html> <html> <head> <title>原鉴定情况</title> <meta charset="UTF-8"/> <script type="text/javascript"> function updatePage(){ var buttons = document.getElementsByName("isHave"); for(var i=0;i<buttons.length;i++){ if(buttons[i].checked && buttons[i].value == "无"){ document.getElementById("oldResult").style.display = "none"; }else if(buttons[i].checked && buttons[i].value == "有"){ document.getElementById("oldResult").style.display = "block"; } } } function addTableRow(tableId) { var table = document.getElementById(tableId); var tr = table.rows[table.rows.length-1].cloneNode(true); table.appendChild(tr); } function del() { var oldTable = document.getElementById("oldResult"); var checks = document.getElementsByName("selected"); for (var i = checks.length-1; i > 0; i--) { if (checks[i].checked) { oldTable.deleteRow(i+1); } } } </script> </head> <body> <table> <tr> <td>原鉴定情况</td> <td> <input type="radio" name="isHave" value="无" onclick="updatePage()" checked="checked"/><label>无</label> <input type="radio" name="isHave" value="有" onclick="updatePage()" /><label>有</label> <table id="oldResult" style="display:none"> <tr> <td colspan="5" align="right"> <input type="button" value="增加" onclick="addTableRow('oldResult')" /> <input type="button" value="删除" onclick="del()" /> </td> </tr> <tr> <td><input type="checkbox" name="selected" class="ckeck"/></td> <td>原鉴定机构</td> <td>原鉴定时间</td> <td>原鉴定结论</td> <td>鉴定书附件</td> </tr> <tr> <td> <input type="checkbox" name="selected" class="ckeck"/> </td> <td> <select name="oranization"> <option value="省">省级物证鉴定中心</option> <option value="市">市级物证鉴定所</option> <option value="县">县级物证鉴定技术室</option> <option value="社">社会司法鉴定机构</option> </select> </td> <td> <input type="text" name="time"/> </td> <td> <input type="text" name="result"/> </td> <td> <input type="button" value="上传" /> </td> </tr> </table> </td> </tr> </table> </body> </html>
柠檬酸钠
相关分类