Expand my Community achievements bar.

SOLVED

Is there anything wrong with this JavaScript code? (simple math formula and if/or statement)

Avatar

Level 2

var nNumber = NumericField1.rawValue - NumericField2.rawValue;

if (nNumber > 2 || NumericField3.rawValue > 5) {

     TextField1.presence = "visible";

     TextField2.presence = "hidden";

}

I can't get seem to get this code to work. Should this code work in terms of the formula, symbols, etc?

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Script looks okay. Is the language set to JavaScript? Is the form saved as a Dynamic XML Form in the save-as dialog?

Niall

View solution in original post

5 Replies

Avatar

Correct answer by
Level 10

Hi,

Script looks okay. Is the language set to JavaScript? Is the form saved as a Dynamic XML Form in the save-as dialog?

Niall

Avatar

Level 2

Yes and Yes... It's chock full of many "if, and, or, else if"statements and it's all working fine except for this code.

I'm thinking that another if statment associated with one of the numeric fields that javascript code is working with, is preventing the code i want from working properly.

I'm going to examine it more later, I just wanted to know if the code should work by the looks of it, thanks.

Avatar

Level 10

Hi,

Open the JavaScript Consolr (Control+J) and then interact with the referenced fields. If there is a problem with the script it is likely that it will show up in the console.

Javascript Console.png

Also check the references to the objects. If the object that contains the script is separated from the references objects, then you will need a fuller reference.

Good luck,

Niall

Avatar

Level 2

Thanks Niall.

By the way, in order for Ctrl + J to open the javascript debugger, users must have javascript debugging enabled in Acrobat Pro first. I had to follow these instructions to get the debugger to run: http://livedocs.adobe.com/livecycle/8.2/acrobat_designer/wwhelp/wwhimpl/common/html/wwhelp.htm?conte...

Another question I just thought of... Should the code I referenced in my original post be placed in the validate, exit or change event?

Avatar

Level 2

I think I've got it now... change and exit events work fine for the objects I'm referencing in the script.

I've also got the all my if/or/else scripts working properly now. I just had to apply the same script to all the affected objects on either the change or exit events.. I'm referencing text fields, numeric fields, a decimal field, and a radio button list. (Just in case anyone else sees this and is wondering).