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

JavaScript Troubleshooting

New Here ,
Apr 26, 2019 Apr 26, 2019

Copy link to clipboard

Copied

Hi Everyone,

I am an amateur at JavaScript, and hope someone can show me where I am going wrong.

My script is:

event.value = "";

var Text1 = this.getField("Text1").value;

if (Text1!="") {

     if (Number(Text1)>20,Number(Text1)<51) event.value = Number(Text1)-20;

     else if (Number(Text1)>50) event.value = 30

else event.value = 0;

}

Which should:

1. If the input value is under 20, output is zero,

2. If the input value is between 20 and 51, output is input value minus 20

3. If the input value is over 50, output value is 30

It works mostly, however, input values under 20 are giving negatives, not zero.

Where have I gone wrong?

TOPICS
Acrobat SDK and JavaScript

Views

213

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 26, 2019 Apr 26, 2019

Copy link to clipboard

Copied

Try this:

event.value = "";

var Text1 = this.getField("Text1").valueAsString;

if (Text1!="") {

    Text1 = Number(Text1);

    if (Text1>20 && Text1<51) event.value = Text1-20;

    else if (Text1>50) event.value = 30;

    else event.value = 0;

}

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 26, 2019 Apr 26, 2019

Copy link to clipboard

Copied

LATEST

Great! Thank worked a charm - I'll remember the multiple conditions convention next time

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