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

JavaScript Calculation Help!

New Here ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

Greetings! I have no experience with script, but trying to create a custom calculation script in my form to auto calculate QTY * Price Per Case = Extended Price for each row.  

KimmarieE_0-1649817682527.png

I found this formula on the Adobe Community, which works, but it also populates the Price Per Case and Extended Price from Row 1 on the rest of the rows. They should be blank until I fill in QTY and Price Per Case.

var firstValue = this.getField("Price Per CaseRow1").valueAsString;

var secondValue = this.getField("QTYRow1").valueAsString;

if (firstValue=="" || secondValue=="") event.value = "";

else event.value = Number(firstValue) * Number(secondValue);

 

KimmarieE_1-1649817682533.png

Please help!

Views

146

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 ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

You are exposing only some of the event handlers associated with the Price Per Case field.
Only the Price Per Case field can be rewritten and controlled here.
The code you have should also contain event handlers for the Extended Price field, so you need to expose that to lead to a solution.

...Maybe.

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 ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

Thanks for the quick reply! Not sure how to add the additional handlers in JavaScript. 🙂  

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 ,
Apr 12, 2022 Apr 12, 2022

Copy link to clipboard

Copied

LATEST

Is it difficult to post all the codes?  of course, confidentiality is a consideration.

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