Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    if then statement comparing text

    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.

  • #2
    New Coder
    Join Date
    Jul 2002
    Posts
    31
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Incorrect syntax for the if statement. Should be:

    if(form.State.value!="NY")

  • #3
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    The if-statement syntax is definitely going to cause an error.

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

  • #4
    New to the CF scene
    Join Date
    Feb 2003
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thanks a lot folks!

    That did the trick, I appreciate your help. I can see this board was a great find!!!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •