<meta http-equiv="content-type" c charset="utf-8"> <title>Select All</title> <style><span> table{ border:<span>#<span>999 1px solid; border-collapse:<span>collapse; } table th{ text-align:<span>center; } table td{ border:1px solid <span>#<span>999; text-align:<span>center; } .<span>one{ background:<span>#<span>6cf;<span> } .<span>two{ background:<span>#<span>fc6;<span> } </style> <script type="text/javascript" language="javascript"> <span>function<span> changecolor(){ <span>var tr=document.getElementsByTagName("tr"<span>); tr[0].style.background="#0066ff"<span>; tr[tr.length-1].style.background="#0066ff"<span>; } <span>function<span> changebox(type) { <span>var tbs = document.getElementById("tbs"<span>); <span>var chks = tbs.getElementsByTagName("input"<span>); <span>switch<span> (type) { <span>case "qx": <span>for (<span>var i = 0; i < chks.length; i++<span>) { chks[i].checked = <span>true<span>; } <span>break<span>; <span>case "qxx": <span>for (<span>var i = 0; i < chks.length; i++<span>) { chks[i].checked = <span>false<span>; } <span>break<span>; <span>case "fx": <span>for (<span>var i = 0; i < chks.length; i++<span>) { <span>if (chks[i].checked == <span>true<span>) { chks[i].checked = <span>false<span>; } <span>else<span> { chks[i].checked = <span>true<span>; } } <span>break<span>; } } <span>function<span> del(){ <span>var input=document.getElementsByName("check[]"<span>); <span>for(<span>var i=input.length-1; i>=0; i--<span>){ <span>if(input[i].checked==<span>true<span>){ <span>var td=input[i].<span>parentNode; <span>var tr=td.<span>parentNode; <span>var table=tr.<span>parentNode; table.<span>removeChild(tr); } } } </script> <tr> <th>选项</th> <th>发件人</th> <th>邮件名称</th> <th>邮件附属信息</th> </tr> <tbody> <tr>class="one"> <td><input type="checkbox" name="check[]"></td> <td>王大力</td> <td>wdl@qq.com</td> <td>个人邮箱</td> </tr> <tr>class="two"> <td><input type="checkbox" name="check[]"></td> <td>王大力</td> <td>wdl@qq.com</td> <td>个人邮箱</td> </tr> <tr>class="one"> <td><input type="checkbox" name="check[]"></td> <td>王大力</td> <td>wdl@qq.com</td> <td>个人邮箱</td> </tr> <tr>class="two"> <td><input type="checkbox" name="check[]"></td> <td>王大力</td> <td>wdl@qq.com</td> <td>个人邮箱</td> </tr> <tr>class="one"> <td><input type="checkbox" name="check[]"></td> <td>王大力</td> <td>wdl@qq.com</td> <td>个人邮箱</td> </tr> <tr>class="two"> <td><input type="checkbox" name="check[]"></td> <td>王大力</td> <td>wdl@qq.com</td> <td>个人邮箱</td> </tr> <tr>class="one"> <td><input type="checkbox" name="check[]"></td> <td>王大力</td> <td>wdl@qq.com</td> <td>个人邮箱</td> </tr> <tr> <th>选项</th> <td colspan="3" align="center"> <input type="button" value="全选"> <input type="button" value="取消全选"> <input type="button" value="反选"> <input type="button" value="删除选选附件"> </td> </tr> </tbody>
以上就介绍了php对表格进行批量操作如全选反选删除功能,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。