Skip to main content
Participant
April 13, 2022
Question

JavaScript Calculation Help!

  • April 13, 2022
  • 1 reply
  • 262 views

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.  

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);

 

Please help!

    This topic has been closed for replies.

    1 reply

    ajabon grinsmith
    Community Expert
    Community Expert
    April 13, 2022

    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.

    Participant
    April 13, 2022

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

    ajabon grinsmith
    Community Expert
    Community Expert
    April 13, 2022

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