日期:2014-05-16 浏览次数:20394 次
<tr align="left"> <td>抄送人:</td> <td id="test"><input type="text" id="carbon" width="50"> <select size=1 name="sd_carboncopy" id="sd_carboncopy"> <option value="">无</option> <%do while not rs.eof%> <option value="<%=rs("username")%>"><%=rs("name")%></option> <% rs.movenext loop rs.close %> </select> <input type="button" value="add" onClick="setname('test');"> <input type="button" value="del" onClick="deleteAll('cp');"></td> <script> function setname(obj) { var copy=document.getElementById("sd_carboncopy").value; document.getElementById(obj).innerHTML += "<input type='checkbox' name='cp'>" + copy + "</input>"; } function deleteAll(obj){ var answer = document.getElementsByName(obj) var len = answer.length; var checked = false; for(var i = 0 ; i < len ; i++) { if(answer[i].checked) { checked = true; break; } } if(checked) { return confirm("确定要删除吗?"); } else { alert("对不起,你没有选择要删除的对象!"); return false; } } </script> </tr>
<input type="checkbox" name="aa" />a <input type="checkbox" name="aa" />b <input type="checkbox" name="aa" />c <input type="checkbox" name="aa" />d <input type="button" value="del" onclick="removechk()" /> </div> <script type="text/javascript" > function removechk() { var os = document.getElementsByName("aa"); for (var i = os.length-1; i >= 0; i--) { if (os[i].checked) { os[i].parentNode.removeChild(next(os[i], 3));//如果是删除下一个元素节点,则next(os[i], 1) os[i].parentNode.removeChild(os[i]); } } } function next(elem, nodetype) {//获得下一个节点 //节点类型,1 元素element,文本text 3,更多节点类型google:html nodetype do { elem = elem.nextSibling; } while (elem && elem.nodeType != nodetype); return elem; } </script>