function check_all() {
var input = document.getElementsByTagName("INPUT");
for(i=0;i<input.length;i++)
{
if(input[i].type == "checkbox" && input[i].checked == false){
input[i].value="0";
}
}
}
var input = document.getElementsByTagName("INPUT");
for(i=0;i<input.length;i++)
{
if(input[i].type == "checkbox" && input[i].checked == false){
input[i].value="0";
}
}
}
选中的为ok. 这样不会循环。去改。
<script language="javascript">
<!--
function check_box(a) {
a.value="ok"
}
}
//-->
</script>
<form name="form1" method="post" action="" onSubmit="return check_box();">
<p>
<input name="p[0]" type="checkbox" onclick="check_box(this);" id="p[0]" value="0">
<input name="p[1]" type="checkbox" onclick="check_box(this);" id="p[1]" value="0">
<input name="p[2]" type="checkbox" onclick="check_box(this);" id="p[2]" value="0">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>