php对表格进行批量操作如全选反选删除功能 !DOCTYPEhtmlhead meta http-equiv="content-type" content="text/html" charset="utf-8" titleSelect All/title style table{ border : # 999 1px solid; border-collapse: collapse; } table th{ text -align: cen
php对表格进行批量操作如全选反选删除功能
<!DOCTYPE>
<html>
<head>
<meta http-equiv="content-type" content="text/html" charset="utf-8">
<title>Select All</title>
<style><span style="color: #000000;">
table{
border</span>:<span style="color: #008000;">#</span><span style="color: #008000;">999 1px solid;</span>
border-collapse:<span style="color: #000000;">collapse;
}
table th{
text</span>-align:<span style="color: #000000;">center;
}
table td{
border</span>:1px solid <span style="color: #008000;">#</span><span style="color: #008000;">999;</span>
text-align:<span style="color: #000000;">center;
}
</span>.<span style="color: #000000;">one{
background</span>:<span style="color: #008000;">#</span><span style="color: #008000;">6cf;</span>
<span style="color: #000000;"> }
</span>.<span style="color: #000000;">two{
background</span>:<span style="color: #008000;">#</span><span style="color: #008000;">fc6;</span>
<span style="color: #000000;"> }
</span></style>
<script type="text/javascript" language="javascript">
<span style="color: #0000ff;">function</span><span style="color: #000000;"> changecolor(){
</span><span style="color: #0000ff;">var</span> tr=document.getElementsByTagName("tr"<span style="color: #000000;">);
tr[</span>0].style.background="#0066ff"<span style="color: #000000;">;
tr[tr</span>.length-1].style.background="#0066ff"<span style="color: #000000;">;
}
</span><span style="color: #0000ff;">function</span><span style="color: #000000;"> changebox(type) {
</span><span style="color: #0000ff;">var</span> tbs = document.getElementById("tbs"<span style="color: #000000;">);
</span><span style="color: #0000ff;">var</span> chks = tbs.getElementsByTagName("input"<span style="color: #000000;">);
</span><span style="color: #0000ff;">switch</span><span style="color: #000000;"> (type) {
</span><span style="color: #0000ff;">case</span> "qx":
<span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">var</span> i = 0; i < chks.length; i++<span style="color: #000000;">) {
chks[i]</span>.checked = <span style="color: #0000ff;">true</span><span style="color: #000000;">;
}
</span><span style="color: #0000ff;">break</span><span style="color: #000000;">;
</span><span style="color: #0000ff;">case</span> "qxx":
<span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">var</span> i = 0; i < chks.length; i++<span style="color: #000000;">) {
chks[i]</span>.checked = <span style="color: #0000ff;">false</span><span style="color: #000000;">;
}
</span><span style="color: #0000ff;">break</span><span style="color: #000000;">;
</span><span style="color: #0000ff;">case</span> "fx":
<span style="color: #0000ff;">for</span> (<span style="color: #0000ff;">var</span> i = 0; i < chks.length; i++<span style="color: #000000;">) {
</span><span style="color: #0000ff;">if</span> (chks[i].checked == <span style="color: #0000ff;">true</span><span style="color: #000000;">) {
chks[i]</span>.checked = <span style="color: #0000ff;">false</span><span style="color: #000000;">;
} </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> {
chks[i]</span>.checked = <span style="color: #0000ff;">true</span><span style="color: #000000;">;
}
}
</span><span style="color: #0000ff;">break</span><span style="color: #000000;">;
}
}
</span><span style="color: #0000ff;">function</span><span style="color: #000000;"> del(){
</span><span style="color: #0000ff;">var</span> input=document.getElementsByName("check[]"<span style="color: #000000;">);
</span><span style="color: #0000ff;">for</span>(<span style="color: #0000ff;">var</span> i=input.length-1; i>=0; i--<span style="color: #000000;">){
</span><span style="color: #0000ff;">if</span>(input[i].checked==<span style="color: #0000ff;">true</span><span style="color: #000000;">){
</span><span style="color: #0000ff;">var</span> td=input[i].<span style="color: #000000;">parentNode;
</span><span style="color: #0000ff;">var</span> tr=td.<span style="color: #000000;">parentNode;
</span><span style="color: #0000ff;">var</span> table=tr.<span style="color: #000000;">parentNode;
table</span>.<span style="color: #000000;">removeChild(tr);
}
}
}
</span></script>
</head>
<body onload="changecolor()">
<table width="400" border="0" align="center">
<tr>
<th>选项</th>
<th>发件人</th>
<th>邮件名称</th>
<th>邮件附属信息</th>
</tr>
<tbody id="tbs">
<tr <span style="color: #0000ff;">class</span>="one">
<td><input type="checkbox" name="check[]"></td>
<td>王大力</td>
<td>wdl@qq.com</td>
<td>个人邮箱</td>
</tr>
<tr <span style="color: #0000ff;">class</span>="two">
<td><input type="checkbox" name="check[]"></td>
<td>王大力</td>
<td>wdl@qq.com</td>
<td>个人邮箱</td>
</tr>
<tr <span style="color: #0000ff;">class</span>="one">
<td><input type="checkbox" name="check[]"></td>
<td>王大力</td>
<td>wdl@qq.com</td>
<td>个人邮箱</td>
</tr>
<tr <span style="color: #0000ff;">class</span>="two">
<td><input type="checkbox" name="check[]"></td>
<td>王大力</td>
<td>wdl@qq.com</td>
<td>个人邮箱</td>
</tr>
<tr <span style="color: #0000ff;">class</span>="one">
<td><input type="checkbox" name="check[]"></td>
<td>王大力</td>
<td>wdl@qq.com</td>
<td>个人邮箱</td>
</tr>
<tr <span style="color: #0000ff;">class</span>="two">
<td><input type="checkbox" name="check[]"></td>
<td>王大力</td>
<td>wdl@qq.com</td>
<td>个人邮箱</td>
</tr>
<tr <span style="color: #0000ff;">class</span>="one">
<td><input type="checkbox" name="check[]"></td>
<td>王大力</td>
<td>wdl@qq.com</td>
<td>个人邮箱</td>
</tr>
<tr>
<th>选项</th>
【本文来自鸿网互联 (http://www.68idc.cn)】<td colspan="3" align="center">
<input type="button" id="qx" onclick="changebox('qx')" value="全选">
<input type="button" id="qxx" onclick="changebox('qxx')" value="取消全选">
<input type="button" id="fx" onclick="changebox('fx')" value="反选">
<input type="button" id="del" onclick="del()" value="删除选选附件">
</td>
</tr>
</tbody>
</table>
</body>
</html>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号