Answered
My attempt as follows:
var CharLev = Number(this.getField("ELC").value); if (CharLev > 10) then var ASBoost = 1; elseif (CharLev > 21) then var ASBoost = 2; else var ASBoost = 0; endif
Simply put, if the value of field ECL is greater than 10 I want the variable ASBoost to be 1. If the value of field ECL is greater than 20 I want the variable ASBoost to be 2. Otherwise ASBoost would be 0 if neither match.
I keep getting an error at var ASBoost = 1 saying I need ";" that is missing. I know I did something wrong, but what? Is the syntax incorrect?
Thanks in advance for helping me in this,
Jim
var CharLev = Number(this.getField("ELC").value);
FWIW, the following is faster, smaller, simpler, and equivalent:
But your main problem is incorrect syntax. It should be:
Note that there is no "then", "elseif", or "endif" in the JavaScript if or if/else statements. You can also use "else if", like:
If you're going to be doing much JavaScript programming, you should invest in a good language reference, such as David Flanagan's "JavaScript: The Definitive Guide" published by O'Reilly.
George