Please someone help with my code

admin

Administrator
Staff member
I have the following code that presents an error. I have an else clause 3 times in a row. I know its wrong. Someone please help with my syntax.

function CheckChoice(whichbox)
{
with (whichbox.form)
{
//Handle differently, depending on type of input box.
if (whichbox.type == "radio")
{
//First, back out the prior radio selection's price from the TOTALQTY:
hiddenTOTALQTY.value = eval(hiddenTOTALQTY.value) - eval(hiddenpriorradio.value);
//Then, save the current radio selection's price:
hiddenpriorradio.value = eval(whichbox.price);
//Now, apply the current radio selection's price to the TOTALQTY:
hiddenTOTALQTY.value = eval(hiddenTOTALQTY.value) + eval(whichbox.price);
}
else
{
//If box was checked, accumulate the checkbox value as the form TOTALQTY,
//Otherwise, reduce the form TOTALQTY by the checkbox value:
if (whichbox.checked == false)
{ hiddenTOTALQTY.value = eval(hiddenTOTALQTY.value) - eval(whichbox.value); }
else { hiddenTOTALQTY.value = eval(hiddenTOTALQTY.value) + eval(whichbox.value); }
}
else
{
//If box was checked, accumulate the checkbox value as the form TOTALQTY,
//Otherwise, reduce the form TOTALQTY by the checkbox value:
if (whichbox.checked == false)
{ hiddensubtotal.value = eval(hiddensubtotal.value) - eval(whichbox.value); }
else { hiddensubtotal.value = eval(hiddensubtotal.value) + eval(whichbox.value); }
}

//Ensure the TOTALQTY never goes negative (some browsers allow radiobutton to be deselected):
if (hiddenTOTALQTY.value < 0)
{
InitForm();
}

//Now, return with formatted TOTALQTY:
return(formatCurrency(hiddenTOTALQTY.value));
}
}
 
Back
Top