Trying to create a form with a Results box that has PASS, FAIL and VOID. When user chooses the Result I want the Comments Text field to display different verbiage if the result is a PASS, FAIL, OR VOID.
I have tried to do this but keep getting errors. I am new to FormCalc. I just want to do an If statement, I'm so confused! :)
Here is what I have: ----- form1.#subform[0].Table2.Row1.DropDownList4::click: - (FormCalc, client) ---------------------
if (DropDownList4 == PASS) then
Comments1.addItem = No leakage detected
Endif
My Product Information:
Acrobat Pro 8 / Windows
Offline

I think the problem is two simple syntax errors:
First, fields in XFA all have a property called "rawValue" which lets you retrieve and/or set its value. In FormCalc, this is the default property at all times. This means that in order to set a field's value in FormCalc, you simply need to use the following syntax:
FieldName = Value
"FieldName", in your case, would be "Comments1".
Second is the fact that you're attempting to assign a string of characters to the Comments1 field however you haven't enclosed those characters in double quotes. Without the double quotes, the FormCalc scripting engine interprets each word as a statement and fails because it doesn't know what "no", "leakage" and "detected" mean. The same goes for the comparison of "PASS" to the DropDownList4 field's value. To fix this problem, simply enclose the string value in double quotes. If, however, you were assigning/comparing a numerical value to the field, then you wouldn't need the double quotes because the scripting engine would recognize the series of digits as a numerical value.
Your script should therefore look like this:
if (DropDownList4 == "PASS") then Comments1 = "No leakage detected" endif
Offline

I just noticed something else that may be causing problems: You're checking for the new value set in the drop down list in its Click event. Whenever you check the drop down list's value in the Click event, you'll always get the value that was last set by the user, not the value that they just picked.
In order to get the value they just selected, you need to move this script into the drop down list's Change event and use the "xfa.event.newText" property ("xfa.event" is an object which provides various information about the event itself). It will contain the value that was selected.
If your drop down list specifies items with text and associated values, then you should make sure you compare the "xfa.event.newText" property to an item value, not an item text:
if (xfa.event.newText == "PASS") then Comments1 = "No leakage detected" endif
Finally, something else to verify is whether the DropDownList4 and Comments1 fields are in the same table row. If they aren't, you will need to access them properly, otherwise you will get errors stating that "DropDownList4" and/or "Comments1" doesn't exist.
Offline
Stefan,
Thank you soooooo much! It's working like a charm.
Offline
AcrobatUsers.com >> User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in