首頁 > 後端開發 > php教程 > php對錶格進行批次操作如全選反選刪除功能

php對錶格進行批次操作如全選反選刪除功能

WBOY
發布: 2016-07-29 09:15:33
原創
998 人瀏覽過

<!DOCTYPE>
<html>
<head>
    <meta http-equiv="content-type" c charset="utf-8">
    <title>Select All</title>
    <style><span>        table{
            border</span>:<span>#</span><span>999 1px solid;</span>            border-collapse:<span>collapse;
        }
        table th{
            text</span>-align:<span>center;
        }
        table td{
            border</span>:1px solid <span>#</span><span>999;</span>            text-align:<span>center;
        }
        </span>.<span>one{
            background</span>:<span>#</span><span>6cf;</span><span>        }
        </span>.<span>two{
            background</span>:<span>#</span><span>fc6;</span><span>        }
    </span></style>

    <script type="text/javascript" language="javascript">
        <span>function</span><span> changecolor(){
            </span><span>var</span> tr=document.getElementsByTagName("tr"<span>);
            tr[</span>0].style.background="#0066ff"<span>;
            tr[tr</span>.length-1].style.background="#0066ff"<span>;
        }
        </span><span>function</span><span> changebox(type) {
            </span><span>var</span> tbs = document.getElementById("tbs"<span>);
            </span><span>var</span> chks = tbs.getElementsByTagName("input"<span>);
            </span><span>switch</span><span> (type) {
                </span><span>case</span> "qx":
                    <span>for</span> (<span>var</span> i = 0; i < chks.length; i++<span>) {
                        chks[i]</span>.checked = <span>true</span><span>;
                    }
                    </span><span>break</span><span>;
                </span><span>case</span> "qxx":
                    <span>for</span> (<span>var</span> i = 0; i < chks.length; i++<span>) {
                        chks[i]</span>.checked = <span>false</span><span>;
                    }
                    </span><span>break</span><span>;
                </span><span>case</span> "fx":
                    <span>for</span> (<span>var</span> i = 0; i < chks.length; i++<span>) {
                        </span><span>if</span> (chks[i].checked == <span>true</span><span>) {
                            chks[i]</span>.checked = <span>false</span><span>;
                        } </span><span>else</span><span> {
                            chks[i]</span>.checked = <span>true</span><span>;
                        }
                    }
                    </span><span>break</span><span>;
            }
        }
        </span><span>function</span><span> del(){
            </span><span>var</span> input=document.getElementsByName("check[]"<span>);
            </span><span>for</span>(<span>var</span> i=input.length-1; i>=0; i--<span>){
                </span><span>if</span>(input[i].checked==<span>true</span><span>){
                    </span><span>var</span> td=input[i].<span>parentNode;
                    </span><span>var</span> tr=td.<span>parentNode;
                    </span><span>var</span> table=tr.<span>parentNode;
                    table</span>.<span>removeChild(tr);
                }
            }
        }
    </span></script>
</head>
<body  border="0" align="center">
    <tr>
        <th>选项</th>
        <th>发件人</th>
        <th>邮件名称</th>
        <th>邮件附属信息</th>
    </tr>
    <tbody>
    <tr <span>class</span>="one">
        <td><input type="checkbox" name="check[]"></td>
        <td>王大力</td>
        <td>wdl@qq.com</td>
        <td>个人邮箱</td>
    </tr>
    <tr <span>class</span>="two">
        <td><input type="checkbox" name="check[]"></td>
        <td>王大力</td>
        <td>wdl@qq.com</td>
        <td>个人邮箱</td>
    </tr>
    <tr <span>class</span>="one">
        <td><input type="checkbox" name="check[]"></td>
        <td>王大力</td>
        <td>wdl@qq.com</td>
        <td>个人邮箱</td>
    </tr>
    <tr <span>class</span>="two">
        <td><input type="checkbox" name="check[]"></td>
        <td>王大力</td>
        <td>wdl@qq.com</td>
        <td>个人邮箱</td>
    </tr>
    <tr <span>class</span>="one">
        <td><input type="checkbox" name="check[]"></td>
        <td>王大力</td>
        <td>wdl@qq.com</td>
        <td>个人邮箱</td>
    </tr>
    <tr <span>class</span>="two">
        <td><input type="checkbox" name="check[]"></td>
        <td>王大力</td>
        <td>wdl@qq.com</td>
        <td>个人邮箱</td>
    </tr>
    <tr <span>class</span>="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>
</table>

</body>
</html>
登入後複製

以上就介紹了php對錶格進行批量操作如全選反選刪除功能,包括了方面的內容,希望對PHP教程有興趣的朋友有所幫助。

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板