Click to See Complete Forum and Search --> : unchecked checkboxes


rogers
12-02-2003, 02:51 PM
Hello,

I have a table within a form. The table contains a number of checkboxes. I would like to have the value of the checkboxes that are unchecked. How can I do this?

Thank you

fredmv
12-02-2003, 03:05 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>untitled</title>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=iso-8859-1" />
<script type="text/javascript">
//<![CDATA[
function getAmount()
{
var c = document.forms[0].elements, not = 0;
for(i=0; i<c.length; i++) if(c[i].checked == false) not++;
alert(not);
}
//]]>
</script>
</head>
<body>
<form action="#">
<div>
<ul>
<li><input type="checkbox" /></li>
<li><input type="checkbox" /></li>
<li><input type="checkbox" /></li>
<li><input type="checkbox" /></li>
<li><input type="checkbox" /></li>
</ul>
</div>
</form>
<form action="#">
<div>
<input type="button" onclick="getAmount();" value="How many are not checked?" />
</div>
</form>
</body>
</html>