Click to See Complete Forum and Search --> : I have a problem with multiple IF statements.


genuine.duck
10-30-2003, 01:54 PM
Hi,

I have coded a new window to open when a total of values that I have allocated to radio buttons is submitted.
I'm self taught so am not sure of the formatting although have spent weeks trying to solve it.
When the values are SUBMITTED the windows will either only open after total > 50 in the first example or works for all values except for between 41 & 50 in the second example.
See txt file for details.
Thanks to anyone who can help.:confused:

jrbp
10-30-2003, 07:48 PM
Ok this may or maynot help:

In the score() function, where you have 2 numbers one of them is >= and the other is <= try putting the javascript and symbol (&&) inbetween them so it looks like this:

function score() {
if (total <= 20)(undertwo());
if (total >= 21 && <= 30)(overtwo());
if (total >= 31 && <= 40)(overthree());
if (total >= 41 && <= 50)(overfour());
if (total >= 51 && <= 60)(overfive());
if (total >= 61)(oversix())
}

Hope this helps.

genuine.duck
10-31-2003, 09:15 AM
Unfortunately the && just brings up a syntax error.
Thanks for trying though.

halifaxrick
10-31-2003, 09:58 AM
I think this will correct the problem.

When using an AND && or OR || each side of the expression is calculated independently.

So this code:

(total >= 21 && <= 30)

Should read:

(total >= 21 && total <= 30)

genuine.duck
11-01-2003, 08:57 AM
After weeks over tearing my hair out and scanning all the books I have at last, thanks to you it works.
Your a star.