javascript - php用户后台管理不能全部选中?

php中文网
发布: 2016-07-06 13:53:43
原创
1032人浏览过

javascript - php用户后台管理不能全部选中?


点击全选或反选只有第一个会变,其他都没有反映


<?php
include("../../admin/public/header.php");
include("../../admin/public/admin_left.php");
$sql="select * from ts_users ";
$res=mysql_query($sql);
$arr=array();
if(mysql_num_rows($res)>0){
    while(($list=mysql_fetch_assoc($res))!=false){
        $arr[]=$list;
    }
}
?>
<div id="div">
<table border=0 cellspacing=0 width="900px">
    <tr height="60px">
        <th>选择</th>
        <th>用户名</th>
        <th>邮箱</th>
        <th>手机</th>
        <th>创建事件</th>
        <th>最后登陆时间</th>
        <th>操作</th>
    </tr>
    <?php if(isset($arr)) {
        foreach ($arr as $vo) {
                ?>
                <tr align="center" height="30px">
                    <td id="td"><input type="checkbox" value="<?=$vo['uid']?>" ></td>
                    <td><?= $vo['uname'] ?></td>
                    <td><?= $vo['email'] ?></td>
                    <td><?= $vo['phone'] ?></td>
                    <td><?= $vo['ctime'] ?></td>
                    <td><?= $vo['mtime'] ?></td>
                    <td>
                        <a href="./delete_uid.php?uid=<?= $vo['uid'] ?>">删除</a>
                        <a href="./update_uid.php?uid=<?= $vo['uid'] ?>">编辑</a>
                    </td>
                </tr>
                <?php
        }
    }
        ?>
    </table>
    <input type="button" value="全选" onclick="allcheck()">
    <input type="button" value="反选" onclick="check()">
    </div>
<script>
    var div=document.getElementById("td");
    var childs=div.childNodes;
    function allcheck(){
        for(var i=0;i<childs.length;i++){
            if(childs[i].nodeName=="INPUT" && childs[i].getAttribute('type')=='checkbox'){
                childs[i].checked=true;
            }
        }
    }
    function check(){
        for(var i=0;i<childs.length;i++){
            if(childs[i].nodeName=="INPUT" && childs[i].getAttribute('type')=='checkbox'){
                if(childs[i].checked==true){
                    childs[i].checked=false;
                }else{
                    childs[i].checked=true;
                }
            }
        }
    }
</script>
</body>
</html>
登录后复制

回复内容:

javascript - php用户后台管理不能全部选中?


点击全选或反选只有第一个会变,其他都没有反映


<?php
include("../../admin/public/header.php");
include("../../admin/public/admin_left.php");
$sql="select * from ts_users ";
$res=mysql_query($sql);
$arr=array();
if(mysql_num_rows($res)>0){
    while(($list=mysql_fetch_assoc($res))!=false){
        $arr[]=$list;
    }
}
?>
<div id="div">
<table border=0 cellspacing=0 width="900px">
    <tr height="60px">
        <th>选择</th>
        <th>用户名</th>
        <th>邮箱</th>
        <th>手机</th>
        <th>创建事件</th>
        <th>最后登陆时间</th>
        <th>操作</th>
    </tr>
    <?php if(isset($arr)) {
        foreach ($arr as $vo) {
                ?>
                <tr align="center" height="30px">
                    <td id="td"><input type="checkbox" value="<?=$vo['uid']?>" ></td>
                    <td><?= $vo['uname'] ?></td>
                    <td><?= $vo['email'] ?></td>
                    <td><?= $vo['phone'] ?></td>
                    <td><?= $vo['ctime'] ?></td>
                    <td><?= $vo['mtime'] ?></td>
                    <td>
                        <a href="./delete_uid.php?uid=<?= $vo['uid'] ?>">删除</a>
                        <a href="./update_uid.php?uid=<?= $vo['uid'] ?>">编辑</a>
                    </td>
                </tr>
                <?php
        }
    }
        ?>
    </table>
    <input type="button" value="全选" onclick="allcheck()">
    <input type="button" value="反选" onclick="check()">
    </div>
<script>
    var div=document.getElementById("td");
    var childs=div.childNodes;
    function allcheck(){
        for(var i=0;i<childs.length;i++){
            if(childs[i].nodeName=="INPUT" && childs[i].getAttribute('type')=='checkbox'){
                childs[i].checked=true;
            }
        }
    }
    function check(){
        for(var i=0;i<childs.length;i++){
            if(childs[i].nodeName=="INPUT" && childs[i].getAttribute('type')=='checkbox'){
                if(childs[i].checked==true){
                    childs[i].checked=false;
                }else{
                    childs[i].checked=true;
                }
            }
        }
    }
</script>
</body>
</html>
登录后复制

id 整个文档只能有一个,用class

I-Shop购物系统
I-Shop购物系统

部分功能简介:商品收藏夹功能热门商品最新商品分级价格功能自选风格打印结算页面内部短信箱商品评论增加上一商品,下一商品功能增强商家提示功能友情链接用户在线统计用户来访统计用户来访信息用户积分功能广告设置用户组分类邮件系统后台实现更新用户数据系统图片设置模板管理CSS风格管理申诉内容过滤功能用户注册过滤特征字符IP库管理及来访限制及管理压缩,恢复,备份数据库功能上传文件管理商品类别管理商品添加/修改/

I-Shop购物系统 0
查看详情 I-Shop购物系统

立即学习PHP免费学习笔记(深入)”;

<td class="td"><input type="checkbox" value="<?=$vo['uid']?>" ></td>
登录后复制

把id='td'换成class='td'

相关标签:
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号