菜鸟求助,判断选择了几个checkbox?
我想实现当点击提交按钮后,先判断有几个checkbox被选中,让后将他们的值当成字符串,输出到textarea中显示,每点击一次按钮,内容就在新的一行显示,现在做好了简单的样子,缺少判断,代码如下:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript">
function _submit()
{
if (document.getElementById("a").checked!="")
{
document.getElementById("txt").value +=document.getElementById("a").value+"\n";
document.getElementById("a").value ="";
}
if (document.getElementById("b").checked!="")
{
document.getElementById("txt").value +=document.getElementById("b").value+"\n";
document.getElementById("b").value="";
}
if (document.getElementById("c").checked!="")
{
document.getElementById("txt").value +=document.getElementById("c").value+"\n";
document.getElementById("c").value="";
}
}
</SCRIPT>
<form name="form1">
<TEXTAREA NAME="txt" ROWS="10" COLS="30" id="txt" ></TEXTAREA>
<!-- <select name="t" id="t">
<option>fdsfdsfdsfdsafd</option>
<option>fdsfadsfafd</option>
</select> -->
<p>
<input name="a" type="checkbox" value="11" id="a" />
fdfdf
<!--<INPUT type="text" NAME="a" id="a" > -->
<input name="b" type="checkbox" value="22" id="b" />
fefefei
<!--<INPUT type="text" NAME="b" id="b" > -->
<input name="c" type="checkbox" id="c" value="33" />
lalal
<!--<INPUT type="text" NAME="c" id="c" > -->
<input type="button" value="提交" />
</p>
</form>
</body>
</html>