These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Writing a conditional and validating

buckynwd
Registered: Jan 6 2011
Posts: 11
Answered

I'm very new to LiveCycle and FormCalc and I was wondering if anyone could help me with the following problem?
 
I trying to design a numeric field that is validated based on a selection of a list item from a drop down list in another form.
 
For example, if I select List Item 1 from the drop-down list field, the numeric field's total would have to be less than 1000.
 
Is it possible to use FormCalc to do that or would I have to use JavaScript?
 
Either way some guidance on what to enter or how to proceed would be much appreciated.

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, it is possible, except maybe for the bit about the other form. Do you mean a selection in a completely separate PDF document? If you do, then you've got a problem.

But for the conditional you just need to be able to write an "if" statement. For example, if the dropdown is named "MyCombo" this the code would look something like this.

if(MyCombo == "Option1") then
$ < 1000
else if (MyCombo == "Option2") then
$ < 2000
endif


A validation event uses the last value evaluated in the script.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

buckynwd
Registered: Jan 6 2011
Posts: 11
Thanks Thom,

I'm using two fields on the same form so it shouldn't be a problem.

But I'm still having problems. WHen I put the following in the script editor under "enter," I keep getting a syntax error on the last line. It looks right to me. I'm not sure what's wrong.

if (OEDCode == "3504 HQ General Council Supervisory Attorney") then
$ < 1500
else if (OEDCode == "3509 NLRBU Field Support Staff") then
$ < 1000
endif
buckynwd
Registered: Jan 6 2011
Posts: 11
OK I got rid of the syntax error, but the script still doesn't work. When I enter any number into the filed, even a number way greater than 1500, I can still enter it with no error. Here is the script I wrote.

SF182.#subform[0].SecC.Total.1c::enter - (FormCalc, client)
if (OEDCode == "3509 NLRBU Field Support Staff") then
$ < 1000
elseif (OEDCode == "3504 HQ General Council Supervisory Attorney") then
$ < 1500
endif

I just don't get what is wrong. Why won't it limit the amount that can be enterred into "$"?
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Good catch with the syntax error!! My Bad:(

The code needs to be placed in the "Validate" event. The "Enter" event is triggered when the mouse enters a field.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

buckynwd
Registered: Jan 6 2011
Posts: 11
When I put it in the validate event, I got a validation error no matter what I entered in the $ field. Given the script that I entered, it should only give the error if I chose "option 1" and enter a value greater than 1000, right? Maybe it has something to do with the way I'm inputting the value in the $ field. I'm not sure what the problem could be. I'll try it again when I get back to the office on Monday. Can't give up now. I'm sure it's one little small thing.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Accepted Answer
Are the dropdown selection is correct? And that the Path to OEDCode is correct?

Change your code to display a debug message, and to handle the case where nothing is selected.

$host.messageBox(Concat(OEDCode," : ",$))

if (OEDCode == "3509 NLRBU Field Support Staff") then
$ < 1000
elseif (OEDCode == "3504 HQ General Council Supervisory Attorney") then
$ < 1500
else
true;
endif

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

buckynwd
Registered: Jan 6 2011
Posts: 11
Thom,

I figured out the problem. Your script was right. The problem was that I was putting the wrong values for the drop-down values. I was putting text where I should have been using the numerical value. Thanks for all your help!!