Skip to main content
Participant
February 11, 2018
Question

Please help with simple conditional equation

  • February 11, 2018
  • 1 reply
  • 517 views

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";

}

This topic has been closed for replies.

1 reply

try67
Community Expert
Community Expert
February 11, 2018

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";

}

Participant
February 11, 2018

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

try67
Community Expert
Community Expert
February 11, 2018

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