checkboxlist能不能只能单选?
checkboxlist能不能只能单选?有没有什么属性做控制的?还是不行啊?
------解决方案--------------------就是要你单选^_^
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> Untitled Page </title>
<script type= "text/javascript ">
function CheckBoxList_Click(sender)
{
var ndx = sender.id.lastIndexOf( "_ ");
var tblId = sender.id.slice(0, ndx);
var tbl = document.getElementById(tblId);
var eles = tbl.getElementsByTagName( "input ");
var senderState = sender.checked;
for(var i=0; i <eles.length;i++) {
eles[i].checked = false;
}
sender.checked = senderState;
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:CheckBoxList ID= "CheckBoxList1_1 " BorderWidth= "1 " runat= "server ">
<asp:ListItem onclick= "CheckBoxList_Click(this) " Value= "Item1 "> Item1 </asp:ListItem>
<asp:ListItem onclick= "CheckBoxList_Click(this) " Value= "Item2 "> Item2 </asp:ListItem>
<asp:ListItem onclick= "CheckBoxList_Click(this) " Value= "Item3 "> Item3 </asp:ListItem>
<asp:ListItem onclick= "CheckBoxList_Click(this) " Value= "Item4 "> Item4 </asp:ListItem>
</asp:CheckBoxList>
</div>
</form>
</body>
</html>