I'm trying to create a JavaScript lease calculator where a user will enter an input (purchase price) and based on the amount that is input will produce a calculation (which further I will add a range to go a certain percentage higher and lower than the calculated number).
Here is an example from my javascript:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function aplusb(form) {
a=eval(Calc.num1.value)
if (a < 1000)
{
b= 0.05372
c=a * b
Calc.Input.value = c
Calc.Input2.value = c - (c * 0.15)
Calc.Input3.value = c + (c * 0.15))
}
else if (1001 < a < 2000)
{
b= 0.04875
c=a * b
Calc.Input.value = c
Calc.Input2.value = c - (c * 0.15)
Calc.Input3.value = c + (c * 0.15))
}
else
{
b= 0.04689
c=a * b
Calc.Input.value = c
Calc.Input2.value = c - (c * 0.15)
Calc.Input3.value = c + (c * 0.15))
}
}
</script>
and the html i'm using to call the script
<form name="Calc" action="--WEBBOT-SELF--" method="POST">
<p>
Enter Purchase Price:
<input type="text" name="num1" size="12" tabindex="1">
<br> Calculation: <input type="text" name="Input" size="17" tabindex="4">
Range
<input type="text" name="Input2" size="17" tabindex="4">
<input type="text" name="Input3" size="17" tabindex="4">
</p>
<input type="button" name="sum" value="Calculate" OnClick="aplusb(this.form)" tabindex="3">
</form>
The script works fine if it's just doing the same calculation on any number, but as soon as I add the "if" command, it doesn't work after that. Essentially there will be a group of about 10 if else commands. Any help would be much appreciated! Thanks!