如何使一个的CheckBoxList只能选择选择一个项目 [英] how to make an checkboxlist select only one item selected
本文介绍了如何使一个的CheckBoxList只能选择选择一个项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是checkboslist绑定到一个DataTable。
但在这里,我需要让用户选择复选框列表中选择只有一个项目
在那里我们可以aachive这样
i am using an checkboslist binding to a datatable. but here i need to make user select only one item selected from checkbox list is there way we can aachive this
无论是JQuery的,JavaScript的,C#
谢谢
either JQuery, javascript, c# thank you
推荐答案
如果用户只允许从列表中选择一个项目,你应该使用,而不是复选框单选按钮。
If the user is only allowed to select one item from a list, you should use radio buttons instead of checkboxes.
更新:
如果你必须使用复选框,那么你可以使用下面的code:
If you have to use checkboxes then you can use the following code:
$("#myform :checkbox").click(function(){
$("#myform input:checked").attr("checked","");
$(this).attr("checked","checked");
});
这篇关于如何使一个的CheckBoxList只能选择选择一个项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文