Skip to main content
garnelll27403510
Participant
April 19, 2017
Question

I need to create a custom script using (+,-) for a drop down menu with 5 options

  • April 19, 2017
  • 2 replies
  • 405 views

Hello

I am editing a form in Acrobat where I have  a drop down menu with 5 options in a field. I need to create a custom script to use addition for the first three options and subtraction for the last two options. Any help would be greatly appreciated.

This topic has been closed for replies.

2 replies

Joel Geraci
Community Expert
Community Expert
April 20, 2017

You may need to elaborate if this answer doesn't help; I really have no idea what you're asking for exactly.

I suspect you want to use the value of the dropdown in a calculation that is in a different field. In that case, just use basic math in your calculation. In your dropdown, just set the last two values to negative numbers.

garnelll27403510
Participant
April 20, 2017

Hello Joel, thanks for your reply.

I have a specific field that has a drop down menu with 5 options (Obligation ,Invoice, Manual Adjustment, Manual Transfer and Set Complete) to select. I am trying to create a script that if 1-3 options were selected then it would add two fields (Current Obligation, Cumulative Obligation). If the last two are selected then it would subtract two fields (Current Obligation, Cumulative Obligation). Hope this clear things up a bit.

Joel Geraci
Community Expert
Community Expert
April 20, 2017

Order matters in subtraction so I'm assuming "subtract two fields (Current Obligation, Cumulative Obligation)" means subtract Current Obligation FROM Cumulative Obligation.

It seems like you think you need to branch your code based on the selection in the list. You don't. You just need to be clever in how you set the values.

In your dropdown, your item names will be your list of five. For the first three export values, you'll enter the number 1. For the last two, enter -1.

You don't supply the actual field names so I have to do this in pseudo code but... your calculation is...

Cumulative Obligation + (Current Obligation * ValueOfYourDropdownField);

Assuming Current Obligation is always positive, when it gets multiplied by the value of the dropdown AND the dropdown value is one of the last two, the value becomes negative and added to the Cumulative Obligation which, effectively, subtracts it. When any of the first three in the list is selected, the number doesn't change and it just gets added.

garnelll27403510
Participant
April 20, 2017

Or can this even be done? I am new to using Java in Acrobat and would appreciate any feedback