0

好的,我每个类别有两个收音机。一种是“允许”,另一种是“拒绝”。每个类别都有一个子类别。每个子猫上都有相同的收音机。我想要做的是,如果有人在主类别中选择“允许”或“拒绝”,则所有该类别子类别都会更改以反映该选择,但允许子类别中的独立更改。

每个类别和子类别都是使用 PHP 和 MySQL 使用循环动态创建的。我知道我需要为每个主猫的每个子猫添加一个唯一的 ID。我只是不知道该怎么做。

        <ul><!-- main category -->
            <li><b><font size="3">Users:</font></b>
                <p class="radioper"><font color="green"> <b>Allowed</b> </font>
                <input type="radio" name="modusers" value="1" checked="">
                <font color="red"> <b>Denied</b> </font>
                <input type="radio" name="modusers" value="0"></p>
            </li>
            <ul><!--Sub-cat -->
                <li><font size="3">Active Users:</font>
                    <p class="radioper"><font color="green"> <b>Allowed</b> </font>
                    <input type="radio" name="fusract" value="1" checked="">
                    <font color="red"> <b>Denied</b> </font>
                    <input type="radio" name="fusract" value="0"></p>
                </li>
            </ul><!-- End Sub-Cat -->
        </ul><!-- End Main Category -->
4

1 回答 1

0

如果您使用的是 jquery 1.6 或更高版本,那么这就是解决方案:

您必须根据您的实际情况添加 id 和分类,但这是一个示例,

<ul><!-- main category -->
    <li><b><font size="3">Users:</font></b>
        <p class="radioper"><font color="green"> <b>Allowed</b> </font>
            <input id="radio-users-allowed" type="radio" name="modusers" value="1" checked>
            <font color="red"> <b>Denied</b> </font>
            <input id="radio-users-denied" type="radio" name="modusers" value="0"></p>
        </li>
        <ul><!--Sub-cat -->
            <li><font size="3">Active Users:</font>
                <p class="radioper"><font color="green"> <b>Allowed</b> </font>
                    <input class="radio-active-users-allowed" type="radio" name="fusract" value="1" checked>
                    <font color="red"> <b>Denied</b> </font>
                    <input class="radio-active-users-denied" type="radio" name="fusract" value="0"></p>
                </li>
            </ul><!-- End Sub-Cat -->
</ul><!-- End Main Category -->

<script type="text/javascript">
    $('#radio-users-allowed').change(function(){
        $('.radio-active-users-allowed').prop('checked', true);
    });
    $('#radio-users-denied').change(function(){
        $('.radio-active-users-denied').prop('checked', true);
    })
</script>
于 2013-11-10T02:00:24.220 回答