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

Calculations not working

New Here ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

I am hoping someone can help me solve this issue with my calculations.  My Total field is not calculating.  I have ZERO knowledge of JavaScript.  I have developed a fillable form where the use will first select a quantity from a dropdown between 1-10 of an item.  If they select a quantity of an item they will then be required to select the Size and then the Length, both of these fields are drop downs.  Failure to select a Size or Length will result in a message telling them they must select this information.  Next, the item has a fixed price per item, and this is a text field..  Lastly, I need to calculate the Total amount that the person is spending based off the Quantity selected and the fixed Price.

 

Ex.  User selects a Quantity of 5 jackets.  They then put in the size as Small and length as Regular.  One jacket costs $149.50.  So the amount in the Total column will show $747.50.  If the user later changes the Quantity of jackets they want to a quantity of 3 the Total column will change to display $448.50.

 

Here's what I have done so far.  The quantity field is a dropdown box.  The Item field is a read only text field.  The Size field is a dropdown box with Custom Calculation event.target.required = (this.getField("Qty1").valueAsString!=this.getField("Qty1").defaultValue); .  The Length field is a dropdown box with Custom Calculationevent.target.required = (this.getField("Size1").valueAsString!=this.getField("Size1").defaultValue); .  The price field is a read only text with the amount for that item.  Lastly, the Total column has the formula Value Is: Product X, Price 1, Qty1.  I have tried to Set Field Calculation order with the Size first, Length second, and Total last.

 

Thank you for all help that can be provided!

TOPICS
JavaScript , PDF forms

Views

1.6K

Translate

Translate

Report

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

What does you get in the total field?

Votes

Translate

Translate

Report

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

Nothing.  The calculation isn't working.  But if I change the calculation to addition it is adding the quantity + 0 and giving a total equal to the quantity.  It is as if the column for price is not recognized in the form.

Votes

Translate

Translate

Report

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

I answered your question by email... What you failed to mention is that your price fields are named using numbers (eg. "149.50"), but have no values. As a result, when you use them in a calculation, the outcome is always zero.

To reiterate:

It's not a good idea to have a field with a number for a name. If you do do that, make sure that value is also the field's default value, otherwise it will disappear when the form is reset, and be considered to be zero.

Votes

Translate

Translate

Report

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

If I change the name of the price field from 149.50 to Price 1 how do I set the value to the price of the item?  Or if I keep the field name as a number how do I set the item price to the default value?

Votes

Translate

Translate

Report

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

I recommend doing both. After renaming the field, go to its Properties window, then under the Options tab set the default value. Don't forget to update the calculation script, and to reset the form when you're done, so the new default value will "kick in" as the field's current value.

Votes

Translate

Translate

Report

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 ,
Feb 28, 2023 Feb 28, 2023

Copy link to clipboard

Copied

LATEST

That did it.  I got it working.  Thank you!!

Votes

Translate

Translate

Report

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