PDA

View Full Version : problems in checkbox



loislane74
09-27-2008, 06:10 PM
here is a code that displays a table of which consists of checkbox and textbox now my problem is i would like to be able to get the sum of values entered by the user in each of the textbox per row as well as per column how will I do it...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<script type="text/javascript">
function disen(c){
var textBoxes=c.parentNode.parentNode.getElementsByTagName('input'), i=1, t;
while(t=textBoxes[i++]){
if(c.checked){t.removeAttribute('disabled');}
else{t.value='';t.setAttribute('disabled','disabled');}
}
}
</script>

</head>
<body>
<table border=0 cellpadding=1 cellspacing=5>
<tr>
<th>Days of Month</th>
<th>Kids</th>
<th>Adults</th>
<th>Volunteers</th>
</tr>
<?php for($i=1;$i<=31;$i=$i+1)
{
echo '<tr>
<td>'.$i.'&nbsp;&nbsp;&nbsp;<input type="checkbox" onclick="disen(this)" name="days['.$i.']"></td>
<td><input type="text" disabled="disabled" size=5></td>
<td><input type="text" disabled="disabled" size=5></td>
<td><input type="text" disabled="disabled" size=5></td>
</tr>';
}
?>
</table>
</body>
</html>