繁体   English   中英

如何在检查另一个单选按钮字段时强制单选按钮保持选中状态?

[英]How to force radio buttons to remain checked when checking another radio buttons field?

嗨我的页面上有两个评级字段,当检查第一个评级时,我检查第二个评级字段,第一个未选中。 这不是后端的问题,因为评级的价值已经保存,但对于访客来说这是一个问题,因为星星消失了。

有没有办法在javascript或jQuery中说:如果这个字段是检查它仍然检查?

<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
<fieldset class="rate">
    <input id="5-stars-1" type="radio" name="firstRate" value="5" />
    <label for="5-stars-1">5</label>
    <input id="4-stars-1" type="radio" name="firstRate" value="4" />
    <label for="4-stars-1">5</label>
</fieldset>

<fieldset class="rate2">
    <input id="5-stars-2" type="radio" name="secondRate" value="5" />
    <label for="5-stars-2">5</label>
    <input id="4-stars-2" type="radio" name="secondRate" value="4" />
    <label for="4-stars-2">5</label>
</fieldset>

你有什么主意吗 ?

如果您需要更多信息或更多来自我的代码提取物,请不要问!

好吧,感谢Rory和Sathish,答案很简单:

无线电设计为一次检查一次,所以我不能做我想要的,而只需要切换到复选框,问题就解决了!

再次感谢 !

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM