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

custom calculation script to add two fields and show the result in a third field only if user enters data into one or both of the 1st two fields

Guest
May 04, 2016 May 04, 2016

I'm trying to write a script that will calculate the sum of two field if there is a value entered into one or both of the fields. So far, the custom calculation in the third field looks like this:

    var c2 = this.getField(“Cargo WeightRow2”).value;

    var t2 = this.getField(“Tare WeightRow2”).value;

    if(c2 == “ ”) && (t2 == “ ”)

    event.value = c2 + t2;

    else if(c2 == “ ”) || (t2 == “ ”)

    event.value = c2 + t2;

    else if(c2 = “ ”) && (t2 = “ ”)

However, I want the user to be able to manually enter a value into the third field if both of the other fields are empty. Please help.

TOPICS
Acrobat SDK and JavaScript , Windows
678
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
LEGEND ,
May 04, 2016 May 04, 2016
LATEST

Have you tried your code in a form?

Do you get any errors displaying as you save the code or test the form?

You need to use a plain text editor and not a word processor with smart quotation marks.

MDN has the JavaScript Reference online for free and Adobe does the same for the Acrobat JavaScript Reference.

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