Copy link to clipboard
Copied
Hello,
I need to get some help on a complex equation for an apparel order form.
When you order a product that is a larger size (2X, 3X or 4X) the price changes to add an additional $3.
I dont know how to communicate that in the form to work properly.
Here is the equation we were using before we had to add a different price for the lager size.
event.value = Number(this.getField("OE336-Total Quantity").valueAsString) * 28
Here is an equation that we tried to use but doesnt seem to work.
var Size-OE336 = this.getField("Size-OE336").valueAsString;
if (Size-OE336=="2X") or (Size-OE336=="3X") or (Size-OE336=="4X") event.value = Number(this.getField("OE336-Total Quantity").valueAsString) * 31;
else event.value = Number(this.getField("OE336-Total Quantity").valueAsString) * 28
I have attached a screen shot of the form as well as a pdf.
Copy link to clipboard
Copied
In JavaScript operator for 'or' is ||, there are other issues, conditions should be inside one parentheses and not separated.
Don't use - (dash) character in variable names.
Your fields in scripts are named incorrectly, you use "OE336-Total Quantity" and actual field names is
"OE336-TotalQuantity".
Try this:
var Size1 = this.getField("Size-OE336").valueAsString;
if(Size1 == "Select One")
event.value = "";
else if (Size1=="2X" || Size1=="3X" || Size1=="4X")
event.value = Number(this.getField("OE336-TotalQuantity").valueAsString) * 31;
else
event.value = Number(this.getField("OE336-TotalQuantity").valueAsString) * 28;
Also you can check 'Commit selected value immediately' in dropdown field properties under 'Options' tab.
Copy link to clipboard
Copied
Thank you very much and I appreciate your help!! this worked perfectly!
Copy link to clipboard
Copied
Another issue with your code are the variable names. You can't use a hyphen in them, as that's used for mathematical operations (minus). Replace it with an underscore, for example.