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

If/Then Converted to a Custom Calculation Script

New Here ,
Jan 19, 2016 Jan 19, 2016

Can anyone help me convert =IF(A2-A1>0, 0, A2-A1) into a Custom Calculation Script for use in an Adobe form?

Thank you!

TOPICS
Acrobat SDK and JavaScript
552
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

correct answers 1 Correct answer

LEGEND , Jan 21, 2016 Jan 21, 2016

If A1 and A2 are field names, then the custom calculation script could look like:

(function () {

    // Get the field values, as numbers

    var A1 = +getField("A1").value;

    var A2 = +getField("A2").value;

    // Set this field's value

    event.value = A2 - A1 > 0 ? 0 : A2 - A1;

})();

Translate
Community Beginner ,
Jan 21, 2016 Jan 21, 2016

event.value = A2-A1>0 ? 0 : A2-A1;

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 ,
Jan 21, 2016 Jan 21, 2016
LATEST

If A1 and A2 are field names, then the custom calculation script could look like:

(function () {

    // Get the field values, as numbers

    var A1 = +getField("A1").value;

    var A2 = +getField("A2").value;

    // Set this field's value

    event.value = A2 - A1 > 0 ? 0 : A2 - A1;

})();

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