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

Creating an "If" Script w/Form calc

jgiampietro
Registered: Oct 20 2009
Posts: 7
Answered

Hello!

To the point: I am trying to create a from wherein the user can make a selection form a drop box of various categories of cabins (I.e. "4B Inside"), and, depending on what the user selects, an output of a certain $ amount will be placed in another field. I have scripted, into the field where I would like the result, the following (no subforms are used, the language is formcalc, so everything should be on the same heriarchal level, language is formcalc):

If (DropDownList1==4) then (Cell2==459.00) elseif (DropDownList1==6) then (Cell2==659.00) endif

This string does not produce an error when tested in reader or within Livecycle, however, it ALWAYS returns the result "0" in Cell2, irrespective of which I choose (4 or 6).

Additionally, if I attempt to refer to DropDownList1 as "4B Inside" in the string, and name the choice in DropDownList1 thusly, I receive a script error where text, as opposed to numbers, begin. Is this function not possible in formcalc, or is it referenced as something other than "If"?

My Product Information:
LiveCycle Designer, Windows
suewhitehead
Registered: Jun 3 2008
Posts: 232
First, let me remind you that you posted your question in Acrobat forum rather than Livecycle forum. You would probably get more help in the correct forum.

Without going too far into your script, I can see that you need to change the "then" statements. You should use == to mean "is equal to" and the = to mean "set it to". So use: then (Cell2=459.00) and
then (Cell2=659.00) . There may be other changes needed. As I said, I just noticed this first. So try it and see if that gets it to work.
jgiampietro
Registered: Oct 20 2009
Posts: 7
Thanks Sue, but this throws off a syntax error where the "=" appears. Perhaps a mod could move this to the appropriate forum or should I re-post?

EDIT: I re-posted in the LiveCycle forum. Mods may close or remove here.
suewhitehead
Registered: Jun 3 2008
Posts: 232
I looked this up in the Form Calc Reference Guide. Try the bottom part. It should be correct.

//example of IF-Then from the Formcalc User Reference:
//if ( Field1 < Field2 ) then
//Field3 = 0
//elseif ( Field1 > Field2 ) then
//Field3 = 40
//elseif ( Field1 = Field2 ) then
//Field3 = 10
//endif

//your script would then be:
if (DropDownList1==4) then
Cell2=459.00
elseif (DropDownList1==6) then
Cell2=659.00
endif
jgiampietro
Registered: Oct 20 2009
Posts: 7
That did it! Thank you very much! If it helps anyone else, if you are referring to a non-numeric value then there must be quotes around the value.

For instance, my script now looks like this:

If (DropDownList1=="4B Inside") then Cell2=459.00 elseif (DropDownList2=="6B Outside") then Cell2=659.00 endif