Php 如果选中复选框1,则选中复选框1值数组中复选框2中的值所在的所有复选框2

Php 如果选中复选框1,则选中复选框1值数组中复选框2中的值所在的所有复选框2,php,javascript,checkbox,Php,Javascript,Checkbox,我有几个复选框,每个代表单个团队id。我在上面有几个复选框,每个复选框代表这些团队的一组。我希望在选中该组时选中单个团队复选框,反之亦然。我在javascript方面非常弱,这可能是最基本的,但我无法理解。我的复选框值是在php中提取的,我试图避免使用JQuery ------------------PHP---组----------- 区域 > --------------------结束PHP----------------------------- <tr >

我有几个复选框,每个代表单个团队id。我在上面有几个复选框,每个复选框代表这些团队的一组。我希望在选中该组时选中单个团队复选框,反之亦然。我在javascript方面非常弱,这可能是最基本的,但我无法理解。我的复选框值是在php中提取的,我试图避免使用JQuery

------------------PHP---组-----------

区域
>
--------------------结束PHP-----------------------------

<tr >
            <th width="2%" class="thead1">
                <input type="button" onclick="SetAllCheckBoxes('adminForm', 'teamarray2[]',true );" value="ALL" ><input type="button" onclick="SetAllCheckBoxes('adminForm', 'teamarray2[]',false );" value="None" >        <th class="thead1">Teams                
            </th><th class="thead1">City</th>

        </tr>

<?php 

for ($i=0, $n=count( $this->rows ); $i < $n; $i++) {
        $row    = $this->rows[$i];
 ?>
 <tr class="etblraw<?php echo $i % 2?>"><td>
    <input type="checkbox" name="teamarray2[]" value="<?php echo $row->id;?>" <?php if (in_array("$row->id",$this->henry5)){echo 'checked="checked"';}else{}?> >
            </td>
            <td>
                <?php
                echo $row->t_name;
                ?>
            </td>
            <td>
                <?php echo $row->t_city;?>
            </td>


        </tr>
----------------Javascript全选函数------------------

<tr >
            <th width="2%" class="thead1">
                <input type="button" onclick="SetAllCheckBoxes('adminForm', 'teamarray2[]',true );" value="ALL" ><input type="button" onclick="SetAllCheckBoxes('adminForm', 'teamarray2[]',false );" value="None" >        <th class="thead1">Teams                
            </th><th class="thead1">City</th>

        </tr>

<?php 

for ($i=0, $n=count( $this->rows ); $i < $n; $i++) {
        $row    = $this->rows[$i];
 ?>
 <tr class="etblraw<?php echo $i % 2?>"><td>
    <input type="checkbox" name="teamarray2[]" value="<?php echo $row->id;?>" <?php if (in_array("$row->id",$this->henry5)){echo 'checked="checked"';}else{}?> >
            </td>
            <td>
                <?php
                echo $row->t_name;
                ?>
            </td>
            <td>
                <?php echo $row->t_city;?>
            </td>


        </tr>
函数设置所有复选框(FormName、FieldName、CheckValue)
{
如果(!document.forms[FormName])
回来
var objcheckbox=document.forms[FormName].elements[FieldName];
如果(!objcheckbox)
回来
var countcheckbox=objcheckbox.length;
如果(!count复选框)
objcheckbox.checked=检查值;
其他的
//设置所有复选框的复选值
对于(变量i=0;i

-----------------end Js------------------------------------------

“…我正试图避免使用JQuery。”-为什么?永远无法让JQuery在我的Joomla 1.6上工作…@user1071915没有任何理由说明任何javascript都不能与任何PHP一起工作,它们是完全独立的实体,其中一个是服务器端,另一个是客户端。碰撞风险为零。
<tr >
            <th width="2%" class="thead1">
                <input type="button" onclick="SetAllCheckBoxes('adminForm', 'teamarray2[]',true );" value="ALL" ><input type="button" onclick="SetAllCheckBoxes('adminForm', 'teamarray2[]',false );" value="None" >        <th class="thead1">Teams                
            </th><th class="thead1">City</th>

        </tr>

<?php 

for ($i=0, $n=count( $this->rows ); $i < $n; $i++) {
        $row    = $this->rows[$i];
 ?>
 <tr class="etblraw<?php echo $i % 2?>"><td>
    <input type="checkbox" name="teamarray2[]" value="<?php echo $row->id;?>" <?php if (in_array("$row->id",$this->henry5)){echo 'checked="checked"';}else{}?> >
            </td>
            <td>
                <?php
                echo $row->t_name;
                ?>
            </td>
            <td>
                <?php echo $row->t_city;?>
            </td>


        </tr>