4 Replies Latest reply on Mar 7, 2008 10:07 AM by Patrick Leckey

# Help with Scripting!

Ok, to first describe what I'm trying to do. Here's a picture for reference: http://smg.photobucket.com/albums/v158/Tameanaka/?action=view&current=Total.jpg

Ok so I want my customers to only have to fill out the first three lines in the picture. For comps/mini they will be entering either 99,199,299,49,69, or 89. For the next two lines it will change for everyone so those don't come into play. Ok now for the shipping lines, I want to create a kind of If..then script. Like if 99 is typed in the top line I want 12.99 to be placed in the shipping line, etc. I have the calculation script working already for the Subtotal line because it's just a simple addition minus the discounts.

Now for Tax, I also want to do an if..then. On the first page of the form the customers address is placed. Could I do something like If State=MN then Subtotal*.065?? Hopefully this is clear enough to understand. I really need help, i'm not used to java only VB.
• ###### 1. Re: Help with Scripting!
Just a note, not an answer. Details matter - you won't be using Java,
you will be using JavaScript. These are different things. These are
important, because if you start looking for help with Java it will be
truly baffling.

Aandi Inston
• ###### 2. Re: Help with Scripting!
Sorry, I meant JavaScript.
• ###### 3. Re: Help with Scripting!
ok, so i've figured out how to do everything except the tax thing. Can I do something like if state=MN subtotal*0.065? or letters don't work with it? Or can I make a check box that'll output to the Tax box the subtotal*.065? Really need help with this one.
• ###### 4. Re: Help with Scripting!
You can do if-checks with characters, they just have to be enclosed in quotes:

var fState = this.getField("State").value;

if ( fState == "MN" ) {
this.getField("Tax").value = parseInt(this.getField("Total").value) * 0.065;
}

That is assuming your field names are "State", "Tax" and "Total".