Please help with simple conditional equation

New Here ,
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

180

Likes

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

Please help with simple conditional equation

New Here ,
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

181

Likes

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
Feb 11, 2018 0
Most Valuable Participant ,
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";

}

Likes

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
Reply
Loading...
Feb 11, 2018 1
New Here ,
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?

Likes

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
Reply
Loading...
Feb 11, 2018 0
Most Valuable Participant ,
Feb 11, 2018

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Feb 11, 2018 0
New Here ,
Feb 11, 2018

Copy link to clipboard

Copied

Nothing there

Likes

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
Reply
Loading...
Feb 11, 2018 0
Most Valuable Participant ,
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.?

Likes

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
Reply
Loading...
Feb 11, 2018 0
Most Valuable Participant ,
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.

Likes

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
Reply
Loading...
Feb 11, 2018 0
New Here ,
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

Likes

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
Reply
Loading...
Feb 11, 2018 0
Most Valuable Participant ,
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".

Likes

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
Reply
Loading...
Feb 11, 2018 0
New Here ,
Feb 11, 2018

Copy link to clipboard

Copied

You tried it and it worked?

Likes

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
Reply
Loading...
Feb 11, 2018 0
try67 LATEST
Most Valuable Participant ,
Feb 12, 2018

Copy link to clipboard

Copied

Yes.

Likes

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
Reply
Loading...
Feb 12, 2018 0