View Full Version : if then statement comparing text

02-21-2003, 02:03 PM
I hope someone can help me out on this, I am somewhat new to java. I have a simple order form on a webpage that I am setting up. When I press the "calculate order" button on my page, I want it to calculate tax only if the "state" text box is "NY".

I have a textbox named "State", a tax variable named "STax" and the following code:

SShipping = Math.round(SShipping);
SSubTotal =(SAmt1 + SShipping);
if form.State.value <> NY { STax = 0;
}else {
STax = Math.round((SAmt1)*.0800);
STotal =SSubTotal + STax;
form.Amt1.value = AddDecimal(SAmt1);
form.Shipping.value = AddDecimal(SShipping);
form.SubTotal.value = AddDecimal(SSubTotal);
form.Tax.value = AddDecimal(STax);
form.Total.value = AddDecimal(STotal);

I keep getting the following java error:

Error: Object expected
Code: 0

I thank you in advance for any help you can give. I am going to keep searching the forum for some clues.

02-21-2003, 02:55 PM
Incorrect syntax for the if statement. Should be:


02-21-2003, 02:57 PM
The if-statement syntax is definitely going to cause an error.

if (form.State.value != 'NY') { STax = 0;
}else {
STax = Math.round((SAmt1)*.0800);

02-21-2003, 06:58 PM
That did the trick, I appreciate your help. I can see this board was a great find!!!