[英]How do I change radio buttons in a sub category based on radio selection of master category?
好的,我每个类别有两个收音机。 一个是“允许的”,另一个是“被拒绝的”。 每个类别都有一个子类别。 每个子猫上都有相同的收音机。 我要尝试做的是,如果有人在主类别中选择“允许”或“被拒绝”,则该类别子类别的所有类别都会更改以反映该选择,但允许在子类别中进行独立更改。
每个类别和子类别都是使用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 -->
如果您使用的是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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.