Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Need help with complex calculation on PDF form for clothes with different sizes and prices

New Here ,
Apr 17, 2023 Apr 17, 2023

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.

TOPICS
PDF forms
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2023 Apr 17, 2023

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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 17, 2023 Apr 17, 2023

Thank you very much and I appreciate your help!! this worked perfectly!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2023 Apr 17, 2023
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines