The code below is suppose to work like …
There are three checkboxes per item. Each item is incremented by number (the one shown below is for brevity sake). When a user checks one of the three boxes for an item, the javascript should fire and perform one of the following …
1) If nah is checked, make sure the done and todo are unchecked
2) If nah is unchecked and neither done or todo are checked, check todo
3) If todo or done is checked, make sure nah is not checked
4) Todo and done may both be checked
Here is my broken code. All help is appreciated!
[code]
<!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”>
<head>
<title>Test Form</title>
</head>
<body>
<script language=”text/javascript”>
function _Check_Boxes(_chk_type,_chk_bid){
alert(‘In function’);
var _todo = document.getElementById(‘todo_’ + _chk_bid);
var _done = document.getElementById(‘done_’ + _chk_bid);
var _nah = document.getElementById(‘nah_’ + _chk_bid);
if (_chk_type==’N’) {
if (_nah.checked==true) {
// If N box is checked, set other to to unchecked
_todo.checked = false;
_done.checked = false;
else
// If it isn’t checked, see if either of the others are.
// If not, check todo
if (_done.checked==false && _todo.checked==false) {
// Just set the todo box
_todo.checked==true;
}
}
else
// Something happened to the done_ or todo_ boxes
if (_done.checked==false && _todo.checked==false) {
// Just set the nah box if neither of the done or todo boxes are checked
_nah.checked==true;
}
}
return true;
}
</script>
<form name=”main_form”>
<table>
<tr>
<td style=’width:60px;text-align:center;font-size:1.6em;font-weight:bold;padding-right:5px;’>Done</td>
<td style=’width:60px;text-align:center;font-size:1.6em;font-weight:bold;padding-right:5px;’>To Do</td>
<td style=’width:60px;text-align:center;font-size:1.6em;font-weight:bold;padding-right:5px;’>Nah!</td>
<td style=’font-size:1.6em;font-weight:bold;’>Item</td>
</tr>
<tr>
<td style=’text-align:center;padding-right:5px;’><input type=”checkbox” name=”done_1″ onClick=”_Check_Boxes(‘D’,1);” style=’font-size:1.5em;’ /></td>
<td style=’text-align:center;padding-right:5px;’><input type=”checkbox” name=”todo_1″ onClick=”_Check_Boxes(‘T’,1);” style=’font-size:1.5em;’ /></td>
<td style=’text-align:center;padding-right:5px;’><input type=”checkbox” name=”nah_1″ onClick=”_Check_Boxes(‘N’,1);” style=’font-size:1.5em;’ checked /></td>
<td style=’font-size:1.3em;’>Test Line</td>
</tr>
</table>
</form>
</body>
</html>