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

FormCalc SumTotal based on drop down value

prespares
Registered: Nov 6 2008
Posts: 47
Answered

Hi Everyone,

Is it possible to use this script in relation to the value in a drop down?

for instance I have two calculations:

1). For cost per lead, where the amount would be the standard "Sum(detail[*].numAmount)"
2). For cost per thousand, where the amount would be divided by 1000.

I was wondering if I could add some scripting that would make the formula "Sum(detail[*].numAmount)" conditional on the binding of the drop down.

Is this possible?

Joe

My Product Information:
LiveCycle Designer, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Yes, it is possible to use the value of a drop down in a calculation script to make the calculation conditional. However, you'll need to explain a bit more about what you want. For example, how is the calculation going to be conditional?

To get the cost per thousand value, just add a calculation script to the "cost per thousand" field and divide the input value by 1000.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

prespares
Registered: Nov 6 2008
Posts: 47
Hi Thom,

Thank you for taking time and sharing your knowledge by answering my question.

Basically I have three fields:
Quantity
Metric
Rate
Amount

The Metric field is a drop down list with four items
Clicks
Leads
Impressions
Prints.

Only impressions need to be divided by the input value of 1000.

When a user input the value for Quantity, they will then need to select the metric, then enter the rate. The amount field is their subtotal

The calculation is then based on the selection of the metric.

Joe
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
So this is for the Amount Calculation?

Since you are already using FormCalc you should stick with it. To make the calculation conditional you'll need to use the "if" statement.
if(Metric == "Clicks") then.. Calcuaiton for Clicks..elseif (Metric == "Leads") then... Leads Calc...elseif (Metric == "Impressions") then... ImpressionsCalc...elseif (Metric == "Prints") then... Prints...endif

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

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

prespares
Registered: Nov 6 2008
Posts: 47
Hi Thom,

That works great. Thank you very much.

Joe