Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript和;PHP_Javascript_Php_Bulk - Fatal编程技术网

使用javascript和;PHP

使用javascript和;PHP,javascript,php,bulk,Javascript,Php,Bulk,我想做一个批量动作函数 我想要的: -多个表中的批量选择,但只有一个 -在每个表中,一个选择框用于选择该表中的所有项目 我的代码示例 <form method="post"> <table class="list1"> <tbody> <tr> <td class="bulkCheckbox nummer"> <input type="checkbox"

我想做一个批量动作函数

我想要的:
-多个表中的批量选择,但只有一个

-在每个表中,一个选择框用于选择该表中的所有项目

我的代码示例

<form method="post">
   <table class="list1">
     <tbody>
       <tr>
          <td class="bulkCheckbox nummer">
            <input type="checkbox" 
            name="checkProducts" onclick="checkAll('list1, this')" />
          </td>
       </tr>
       <tr>
         <td>
           <input class="bulkCheckbox" type="checkbox" 
           name="bulkCheckProduct[]" value="2810" />
         </td>
         <td>
           <input class="bulkCheckbox" type="checkbox" 
           name="bulkCheckProduct[]" value="2811" />
         </td>
       </tr>
     </tbody>
   </table>

   <table class="list2">
     <tbody>
       <tr>
          <td class="bulkCheckbox nummer">
            <input type="checkbox" 
            name="checkProducts" onclick="checkAll('list2, this')" />
          </td>
       </tr>
       <tr>
         <td>
           <input class="bulkCheckbox" type="checkbox" 
           name="bulkCheckProduct[]" value="2812" />
         </td>
         <td>
           <input class="bulkCheckbox" type="checkbox" 
           name="bulkCheckProduct[]" value="2813" />
         </td>
       </tr>
     </tbody>
   </table>
</form> 



<script>
function checkAll(table, bx) {

    var checkname = document.table.getElementsByClassName("bulkCheckbox");

    for (i = checkname.length; i--; ) {
        checkname[i].checked = bx.checked;
    }
}
</script>
我所尝试的,没有任何效果。

尝试下面的代码


函数checkAll(表,bx){
var checkname=document.getElementsByClassName(“bulkCheckbox”);
for(i=checkname.length;i--;){
console.log(checkname[i]);
控制台日志(bx);
checkname[i].checked=bx.checked;
}
}

谢谢你的回复,这对我很有效,但有一件事。现在它检查所有复选框,因为不再使用变量
table
。此变量用于将表彼此分开。但我无法将此变量与
getElementsByClassname
Uncaught TypeError: Cannot read property 'getElementsByName' of undefined