全选,反选,全不选代码

 

<?php

//连接数据库
include "../userManage/include/dbConn.php";
$sql="select * from user";

$a=mysql_query($sql);

?>
<html>
<head>
<link rel="stylesheet" href="inc/css.css" type="text/css" />
<META http-equiv=Content-Type content="text/html; charset=utf-8">
</head>
<body>

//建表
<form name="form1" method="post" action="">
  <table width="1052" border=0 align=center cellpadding=2 cellspacing=1 bordercolor="#799AE1" class=tableBorder>
    <tbody>
      <tr>
        <th align=center colspan=16 style="height: 23px">竞拍项目管理</th>
      </tr>
      <tr bgcolor="#DEE5FA">
        <td colspan="16" align="center" class=txlrow>&nbsp;</td>
      </tr>
      <tr align="center" bgcolor="#799AE1">
        <td width="6%" align="center" class="txlHeaderBackgroundAlternate">选定</td>
        <td width="7%" align="center" class=txlHeaderBackgroundAlternate>用户id</td>
        <td width="9%" align="center" class=txlHeaderBackgroundAlternate>用户</td>
        <td width="8%" align="center" class=txlHeaderBackgroundAlternate>password</td>
        <td align="center" class=txlHeaderBackgroundAlternate>权限</td>
        <td colspan="2" align="center" class=txlHeaderBackgroundAlternate类型</td>
      </tr>
  
   <?php
   while($array=mysql_fetch_array($a)){
   ?>

//把数据库的信息传到表单里
    <tr>
    <td><input type="checkbox" name="idlist[]" value="<?php echo $array['id'];?>"></td>
   <td><input type="text" name="pid" value="<?php echo $array['id'];?>"></td>
    <td><input type="text" name="pusername" value="<?php echo $array['username'];?>"></td>
     <td><input type="text" name="ppassword" value="<?php echo $array['password'];?>"></td>
   <td><input type="text" name="plimit" value="<?php echo $array['limit'];?>"></td>
    <td><input type="text" name="ptype" value="<?php echo $array['type'];?>"></td>
    </tr>
 <?php
 }
    ?>
          <tr bgcolor="#DEE5FA">
        <td colspan="16" align=center bgcolor="#DEE5FA" class=txlrow>
      
          <label></label>
          <span class="tablebody2">
          <input type="button" value="全选" name="Submit2" onClick="selectAll('qx')" />
    <input type="button" value="反选" name="Submit2" onClick="selectAll('fx')" />
    <input type="button" value="全不选" name="Submit2" onClick="selectAll('qbx')" />
    <input type="button" value="添加" name="tianjia">
    <input type="button" value="删除" name="shanchu">
    <input type="button" value="修改" name="xiugai">
    <input type="button" value="查询" name="chaxun">
          </span>
        <input type="submit" name="ok" value="确定" class="but"></td>
      </tr>
      <tr bgcolor="#DEE5FA">
        <td colspan=16 align=center class=txlrow></td>
      </tr>
 
</tbody></table>
</FORM>

<script  language="javascript"> 
       function  selectAll(type) 
       { 
     var obj=document.getElementsByName("idlist[]"); 
  if(type=='qx'){
  for(var i=0;i<obj.length;i++){ 
         obj[i].checked="true";
     }
   }
   if(type=='qbx'){  
  for(var i=0;i<obj.length;i++){ 
         obj[i].checked="";
   }
       }
     if(type=='fx'){
  for(var i=0;i<obj.length;i++){
 
         if(obj[i].checked){
   obj[i].checked="";
   }else{  
   obj[i].checked="true";
   }
   }
       } 
    }
</script>

</BODY>
  </HTML>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值