js代码
<script language="javascript">
var len = document.customerForm.yangshu.length;
var checked = false;
for (i = 0; i < len; i++)
{
if (document.customerForm.yangshu[i].checked == true)
{
checked = true;
break;
}
}
if (!checked)
{
alert("请至少选择一个双氧度数!");
return false;
}
</script>
form内容:
<form name="customerForm" onsubmit="return check()" method="post">
<table>
<tr>
<td height="25" bgcolor="#FFFFFF">
<div align="center" class="STYLE1">
双氧度数
</div>
</td>
<td height="25" bgcolor="#FFFFFF" class="STYLE2 STYLE1">
<input type="checkbox" name="yangshu" value="1">
3%
<input type="checkbox" name="yangshu" value="2">
6%
<input type="checkbox" name="yangshu" value="3">
9%
<input type="checkbox" name="yangshu" value="4">
12%
</td>
</tr>
<input type="submit" name="Submit" value="提交">
</table>
</form>
接收处理页面:
jsp代码:
String[] xiangmu = request.getParameterValues("xiangmu");
if (xiangmu != null && !xiangmu.equals("")) {
for (int i = 0; i < xiangmu.length; i++) {
if (xiangmu[i].equalsIgnoreCase("1"))
ju = "1";
if (xiangmu[i].equalsIgnoreCase("2"))
ran = "2";
if (xiangmu[i].equalsIgnoreCase("3"))
tang = "3";
if (xiangmu[i].equalsIgnoreCase("4"))
washcut = "4";
}
}