jsp中复选框取值问题,判空解决不了.(100分)
问题是,如果复选框选中了,这个页面不会出问题,但是如果没有选,就会报错,
我做了判断空值处理,if(testfx_ck1.length> 0),但是仍会报
java.lang.NullPointerException错误,请问我错在哪里!
testfx.html
<html xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<title> 无标题文档 </title>
</head>
<body>
<form id= "form1 " name= "form1 " method= "post " action= "testfx.jsp ">
<p>
<input type= "checkbox " name= "mm " value= "a " onclick= "checkItem(this, 'mmAll ') " />
<br />
<input type= "checkbox " name= "mm " value= "b " onclick= "checkItem(this, 'mmAll ') " />
<br />
<input type= "checkbox " name= "mm " value= "c " onclick= "checkItem(this, 'mmAll ') " />
<br />
<input type= "checkbox " name= "mm " value= "d " onclick= "checkItem(this, 'mmAll ') " />
<br />
<input type= "checkbox " name= "mm " value= "e " onclick= "checkItem(this, 'mmAll ') " />
<br />
<input type= "checkbox " name= "mmAll " onclick= "checkAll(this, 'mm ') " />
全选与不全选的切换
<script language= "JavaScript " type= "text/javascript ">
</script>
</p>
<p>
<input type= "submit " name= "Submit " value= "提交 " />
</p>
</form>
<script language=javascript> function checkAll(e, itemName)
{
var aa = document.getElementsByName(itemName);
for (var i=0; i <aa.length; i++)
aa[i].checked = e.checked;
}
function checkItem(e, allName)
{
var all = document.getElementsByName(allName)[0];
if(!e.checked) all.checked = false;
else
{
var aa = document.getElementsByName(e.name);
for (var i=0; i <aa.length; i++)
if(!aa[i].checked) return;
&