js全选例子一个

<html>
<head>

 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <meta http-equiv="Cache-Control" content="no-store" />
 <meta http-equiv="Pragma" content="no-cache" />
 <meta http-equiv="Expires" content="0" />

 

<script type="text/javascript">

function fSelectAll(obj,list)
{
    if(!(obj&&list))
 {

     return;
 }
 if(list.length)
 {

  for(var i=0;i<list.length;i++)
     {
         list[i].checked=obj.checked;
     }
 }
 else
 {
     list.checked=obj.checked;
 }
}
 
 </script>
</head>

<body>
     
        <table >
         
           <tr>
               <td >全选<input type="checkbox" onclick="fSelectAll(this,document.all('form1').id)"></td>
               <td >厂家名称</td>
           </tr>
           <form name="form1" >
    
     <tr  >
            <td ><input type="checkbox" name="id" value="1"></td>
            <td>华为</td>
           </tr>
    
     <tr  >
            <td ><input type="checkbox" name="id" value="2"></td>
            <td>中兴</td>
           </tr>
    
     <tr  >
            <td ><input type="checkbox" name="id" value="3"></td>
            <td>思科</td>
           </tr>
    
     <tr  >
            <td ><input type="checkbox" name="id" value="4"></td>
            <td>阿尔卡特</td>
           </tr>
    
     <tr >
            <td ><input type="checkbox" name="id" value="5"></td>
            <td>诺西</td>
           </tr>
    
     </form>
        </table>
       
</body>
</html>

你可能感兴趣的:(JavaScript,html,cache,华为,中兴)