复选框列表选择问题 [英] checkbox list selection problem
本文介绍了复选框列表选择问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个复选框列表,里面有一些项目..
我还添加了一个项目..
现在我想这样...那个
当我检查具有名称的项目时,所有其他复选框列表项目都将被取消选中...
Plzzz帮我解决问题
I have a checkboxlist having some items in it ..
I had also added an item in it..
Now I want to do like this... that
when i check the item having name then all the other checkboxlist items get unchecked ...
Plzzz help me out
推荐答案
您需要使用循环来取消选中所有项目.
Hi,
you need to use loop to uncheck all the items.
foreach (ListItem li in checkboxlist.Items)
{
li.Selected = false;
}
您是否尝试过任何方法.很简单.
将javascript附加到这样的列表项
CheckBoxList1.Items[2].Attributes.Add("onclick", "unCheckCheckList(''" + CheckBoxList1.ClientID + "'', ''*'')");
在javascript中清除支票
Have you tried anything. It is simple.
Attach a javascript to the list item like this
CheckBoxList1.Items[2].Attributes.Add("onclick", "unCheckCheckList(''" + CheckBoxList1.ClientID + "'', ''*'')");
In the javascript clear the check
function unCheckCheckList(table, sel_value) {
var tableElement = document.getElementById(table);
var children = tableElement.getElementsByTagName("input");
for (i = 0; i < children.length; i++) {
if (children[i].value != sel_value) {
children[i].checked = "";
}
}
}
请找到类型为复选框的子代并在其中分配选中标记.
please find childer of type checkbox and assign checkmark in it.
这篇关于复选框列表选择问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文