Hi,
I have three checkboxes, worth 40,40, and 20. I wish to return a total to a textbox, based on which are checked. Here is the JS routine:
function recalculate(f) {
alert("here");
var total=0;
(if f.elements["chk2006"].checked){
total+=40;
}
(if f.elements["chk2005"].checked){
total+=40;
}
(if f.elements["chk2004"].checked){
total+=20;
}
f.elements["txtTotal"]=total;
return;
{
The form name is "f". Here is one of the checkboxes:
<input type="checkbox" name="chk2004" ></Input>
And here is a button to call the routine:
Input type="button" value="recalculate" onclick="recalculate()" />
When I click the button, I do not see the alert box. And the error is:
Line 124: (the line of the button)
Char: 1
Error: Object expected
Code: 0
I had originally tried calling the routine direct from clicking on the checkboxes themselves but the same error would occur for three lines (the three lines where the checkboxes are.
I don't understand what else to try. Help!
THanks,
KB
I have three checkboxes, worth 40,40, and 20. I wish to return a total to a textbox, based on which are checked. Here is the JS routine:
function recalculate(f) {
alert("here");
var total=0;
(if f.elements["chk2006"].checked){
total+=40;
}
(if f.elements["chk2005"].checked){
total+=40;
}
(if f.elements["chk2004"].checked){
total+=20;
}
f.elements["txtTotal"]=total;
return;
{
The form name is "f". Here is one of the checkboxes:
<input type="checkbox" name="chk2004" ></Input>
And here is a button to call the routine:
Input type="button" value="recalculate" onclick="recalculate()" />
When I click the button, I do not see the alert box. And the error is:
Line 124: (the line of the button)
Char: 1
Error: Object expected
Code: 0
I had originally tried calling the routine direct from clicking on the checkboxes themselves but the same error would occur for three lines (the three lines where the checkboxes are.
I don't understand what else to try. Help!
THanks,
KB