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

Code to Calculate Nearby Field

jossaraf
Registered: Nov 14 2007
Posts: 2

How do you create a javascript popup for feedback when a user selects a specific dropdown list item? For example, on my pdf expense report one of the dropdown list items is breakfast, lunch or dinner. Once either of these 3 are selected, we have a perdiem rate that needs to subtract from the amount put in and calculate this on the nearby expense amount field.

My Product Information:
LiveCycle Designer, Windows
pddesigner
Registered: Jul 9 2006
Posts: 858
Try this alternative:

1. Create a como box (named perdiem) with options - Breakfast, Lunch, and Dinner

2. Add a Text Field (named allowed) and add this Custom Calculation Javascript from the Calculate tab.

var c = this.getField("perdiem")

{

if
(c.value == "Breakfast")
(event.value = 16);
else

if
(c.value == "Lunch")
(event.value = 59);
else

if
(c.value == "Dinner")
(event.value = 48);

}


3. Add a Text field (named paid)

4. Add another Text field (named Total) and add this Custom Calculation Javascript from the Calculate tab.

var a = this.getField("allowed");
var b = this.getField("paid");
event.value = b.value - a.value;

The format for the Text fields should be set to numbers, two decimal place, and dollar sign. If the user paid less than the perdiem, you'll have a negative value. You'll need to add a reset action to the page when it is closed or add a button to reset all fields.

My favorite quote - "Success is the ability to go from one failure to another with no loss of enthusiasm.