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

Please help with simple conditional equation

New Here ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

I'm not familiar with coding languages at all, but I'm trying to make a conditional equation on an Acrobat form.  This is what I've pieced together by looking at other forums.  Could I have someone fix whatever is wrong with it? Please. There are just the 3 values from the "size" field that return one of the 3 values for the "size mod" field.

if (Size = "M") {

    Size Mod = "0";

}

else if (Size = "L") {

    Size Mod = "-1";

}

else if (Size = "S") {

    Size Mod = "1";

}

TOPICS
Acrobat SDK and JavaScript

Views

395

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

There's quite a lot wrong with this code. Use this, instead (place it as the custom calculation script of the "Size Mode" field):

var size = this.getField("Size").valueAsString;

if (size == "M") {

    event.value = "0";

} else if (size == "L") {

    event.value = "-1";

} else if (size == "S") {

    event.value = "1";

}

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

Acrobat accepted that equation. However, when I enter one of the 3 values for "Size", nothing happens to "Size Mod". Am I missing something?

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

Check the JS Console (Ctrl+J) for error messages.

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

Nothing there

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

I'll need to see the file to be able to help you further.

Can you share it with us via Dropbox, Google Drive, Adobe Cloud, etc.?

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

I got the file. Why did you edit the code I provided? There's a reason why I wrote it the way I did.

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

I originally cop and pasted it, but when it was staying blank I tried tinkering with it to see what effects it’d have

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

Use the code I provided as-is and it will work.
Note that JS is case-sensitive, though, so if you enter "s" into the Size field it won't work. Only "S".

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 ,
Feb 11, 2018 Feb 11, 2018

Copy link to clipboard

Copied

You tried it and it worked?

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 ,
Feb 12, 2018 Feb 12, 2018

Copy link to clipboard

Copied

LATEST

Yes.

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