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";
}
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";
}
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?
Copy link to clipboard
Copied
Check the JS Console (Ctrl+J) for error messages.
Copy link to clipboard
Copied
Nothing there
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.?
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.
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
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".
Copy link to clipboard
Copied
You tried it and it worked?
Copy link to clipboard
Copied
Yes.