我有一个按优先级编号分组的复选框列表,我想要一种方式,用户可以从不同的优先级组中选择多个,但每个优先级组只能选择一个
<input type='checkbox' value='1' name='priority[]' />first choice in priority 1 group<br>
<input type='checkbox' value='2' name='priority[]' /> second choice in priority 1 group <br>
<input type='checkbox' value='3' name='priority[]' /> third choice in priority 1 group <br>
<input type='checkbox' value='4' name='priority[]' /> first choice in priority 2 group <br>
<input type='checkbox' value='5' name='priority[]' /> second choice in priority 2 group <br>
<input type='checkbox' value='6' name='priority[]' /> third choice in priority 2 group <br>
因此,在上面的示例中,用户可以选择 1 和 5,因为它们在不同的优先级组中,而不是 1 和 2,因为它们在相同的优先级组中
所以我一直在考虑使用 javascript 在选中一个复选框时禁用组中的其他复选框,例如,如果我选择 1,则禁用 2 和 3,但不会禁用 4、5 或 6
我一直在查看 jQuery 的库中是否有任何内容但看不到任何内容,我想知道是否可以使用 id 或 tabindex 将复选框分组在一起,然后以这种方式禁用但到目前为止还没有运气复选框是从数据库表动态生成,因此我可以在需要时对它们进行排序或在它们周围添加 div 有人可以帮忙吗?
干杯
麦克风