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

Calculate from Dropdown

Student_Vienna
Registered: Jul 30 2007
Posts: 8

Hello,
 
i want to create a textfield, where the sum of values from around 24 dropdown fields is displayed. Its important that i get the values (e.g. 1, 2) not the displayed text in the field.
I'm using Adobe lifeCycle Designer.
I know how to do it with Acrobat Pro, but i've chosen the Designer for my form.
Is there any function or a jscript?
 
Please help me.
 
Yours,
 
Michael

My Product Information:
Acrobat Pro 7.0.0, Windows
sconforms
Expert
Registered: Jul 10 2007
Posts: 92
Assuming the 24 drop down lists and the summation field (which should really be a numeric field rather than a text field) are all contained within the same subform, then all you need to do is add script to the summation field's Calculate event to add the values of the drop down fields.

If you write your script in JavaScript (make sure you specify JavaScript as the language in the Script Editor when you're editing the Calculate event), it would look like this:

drop1.rawValue + drop2.rawValue + ... + drop24.rawValue;

Notice there's no assignment. That's because the scripting engine looks for a value set by the event.

This way, whenever the user picks a new item from any of the drop down lists, the summation field's value will automatically be recalculated.

Depending on how you've setup your form, you may also be able to use FormCalc to make the summation easier. If you've given the same name to all the drop down lists, then you'll have occurrences of a drop down list (such as droplist[0], droplist[1], ..., droplist[23]). In that case, you can use the FormCalc "Sum()" function to do the work for you. In the summation field's Calculate event, you would set the language to FormCalc and use the following script:

Sum(droplist[*])

This would set the summation field's value to the sum of all occurrences of the "droplist" field.

Stefan Cameron obtained his bachelor's degree with Honors in Computer Science at the University of Ottawa and is a Computer Scientist working on Adobe's LiveCycle server products, in particular on LiveCycle Designer ES for the past 5 years.

Student_Vienna
Registered: Jul 30 2007
Posts: 8
Hi,

I did as you told me using javascript.
But with
drop1.rawValue + drop2.rawValue + ... + drop24.rawValue;
I get the Values listed!
E.G: my dropdownfields are named A, B and C
my script is "calculate": A.rawValue + B.rawValue + C.rawValue;

possible Values are 0,1,2,3
then when at A 0 is selected
at B 2
and at C 3
my textfield with the calculate event looks like: 023, theres no calculation!

What I've done wrong?

Yours,
Michael