有很多组多选框(一组4个) 判断每组只能选一个的脚本怎么写 求指教
解决方案 »
- 新浪微博-开放平台V2 CHM离线文档,方便查询
- IE自带的调式工具 为什么调式按钮不能用?
- js对象周期问题?
- 如何在用javascript实现在新的窗口中打开网页
- 如何使用window.open打开新窗口,并向新窗口写入html代码
- 如何在用showModalDialog打开的窗口中获得父窗口中的内容
- JS中的参数传递竟然都是传值的?怎么能这样?!!
- help:如何在javascript取得test.htm?id=ddd后面id的值?
- 如何取出一组checkbox的值,有一个或多个checkbox,checkbox动态生成的,多谢
- 有没有办法防止<Frameset>拖动?
- 鼠标点击切换背景问题
- 这2个有啥区别
cs=document.getElementsByName("name1")
for(m=0;m<cs.length;m++)
{
if(cs[m].checked) i++;
}
if(i>1)
{
alert("只能 one")
}
<asp:CheckBox ID="CheckBox1" runat="server" Text=' <%#Eval("Answer") %>'>
哪个属性调用的?
<%@ Page Language="C#" %><!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 id="Head1" runat="server">
<title></title> <script>
function chk() {
for (i = 1; i < 4; i++) {
cs = document.getElementById("CheckBoxList" + i).getElementsByTagName("input")
j = 0;
for (m = 0; m < cs.length; m++) {
if (cs[m].checked) j++;
}
if (j > 1) {
alert("CheckBoxList" + i + " 只能 选一个");
}
}
}
</script></head>
<body>
<form id="form1" runat="server">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" RepeatDirection="Horizontal"
RepeatLayout="Flow">
<asp:ListItem>A</asp:ListItem>
<asp:ListItem>B</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
</asp:CheckBoxList>
<br />
<asp:CheckBoxList ID="CheckBoxList2" runat="server" RepeatDirection="Horizontal"
RepeatLayout="Flow">
<asp:ListItem>AA</asp:ListItem>
<asp:ListItem>BB</asp:ListItem>
<asp:ListItem>CC</asp:ListItem>
</asp:CheckBoxList>
<br />
<asp:CheckBoxList ID="CheckBoxList3" runat="server" RepeatDirection="Horizontal"
RepeatLayout="Flow">
<asp:ListItem>AA</asp:ListItem>
<asp:ListItem>BB</asp:ListItem>
<asp:ListItem>CC</asp:ListItem>
</asp:CheckBoxList>
<input type="button" value="check" onclick="chk()" />
</form>
</body>
</html>