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

Passing Export Value of one combobox field to another text field

shawnash
Registered: Dec 16 2009
Posts: 48

Hello,

I am new to programming in Adobe forms. I was wondering how you would pass the "export value" for the corresponding "value" of a combo box field with dropdown list - to a text field? So that when the user would select something from the dropdown, it would fill in the text field with the corresponding value. I know there has got to be a way to do this. Maybe a for loop?

Thanks in advance.

My Product Information:
Acrobat Standard 5.x or older, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You can use a custom JavaScript calculation script in the text field to add the value of combo box.
event.value = this.getField('Combo Box1').value;
You might want to read some of the JavaScript tutorials about calculations and combo boxes and view some of the eSeminars dealing with forms and JavaScript.

George Kaiser

shawnash
Registered: Dec 16 2009
Posts: 48
I tried your suggestion, but I got an error when I ran the statement - event.value = this.getField('DeptCombo').Value;

error msg below.
uncaught exception:Field DeptDescr:Calculate:1: Invalid or unknown Event.value, set not possible.

I actually want to bring over the "Export Value" of the DeptCombo field, but it did not even bring over the "value" - any other suggestions?

Thanks, Shawn
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Check your capitalization of 'value'.

You should read the Acrobat JavaScript API Reference and Guide.

For a field the 'exportValues' only apply to radio buttons and check boxes.

For combo boxes and list boxes, export values only have meaning for setting the values of the field and the value of the field is the export value if set or the 'item' if no export value is entered.

George Kaiser

shawnash
Registered: Dec 16 2009
Posts: 48
Ok, thank you for all your help. Do you know why I got an error when I ran the above statement? I am running Acrobat 5 - could this have anything to do with it?

Anyway, can I do a case statement like in VBS or an if elseif statement referencing the value of the DeptCombo field? If so, do you have an example of what the code should look like to accomplish this? Example if DeptCombo = "19" then "ITS" should be in the DeptDesc text field?

Thanks again, Shawn
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
There is no "Value" property in Acrobat JS, there are only the 'value' and 'valueAsString' properties. The error is saying it does not know how to set an item to an unknown property.

You can use the [url=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference]JavaScript[/url] '[url=https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Statements/switch]switch[/url]' statement.

George Kaiser

shawnash
Registered: Dec 16 2009
Posts: 48
Thanks - when I change the capital V to lowercase v for value - it worked!

But, I still was wondering if there was a way to do an if statement to pull check the value of DeptCombo (which will have multiple values) and put a value into DeptDesc based on the value of DeptCombo. I know what I need to do, but just dont know the sytax of how it needs to be in Adobe. Do you know how I could accomplish this - See below..

if DeptCombo.value = 10 then DeptDesc.value = ITS or
if DeptCombo.value = 20 then DeptDesc.value = Finance or
if DeptCombo.value = 30 then DeptDesc.value = Purchasing
etc...

Thanks again, Shawn
try67
Expert
Registered: Oct 30 2008
Posts: 2398
What you describe is not an "or" situation, but an "if-else" situation, and the syntax for it is as follows:
if (condition1) {// Do A} else if (condition2) {// Do B} else if (condition3) {// Do C} else { // if none of the conditions above is met// Do D}

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
You really need to learn how to perform simple task in Acrobat JavaScript. Assuming you are using a custom calculation script

As previously noted, you can use the 'switch' statement:
// using the dept combo valueswicth(this.getField('DeptCombo').value) {case 10:event.value = 'ITS';break;case 20:event.value = 'Finance'break;case 30:event.value = 'Purchasing'break;// etc...default:// no selection or unknown department codeevent.value = '';break;

As noted you can use the 'if' statement.
// get dept combo's field valuevar DeptCode = this.getField('DeptCombo').value;event.value = ''; // assume unknown or no selectionif(DeptCode == 10) event.value = 'ITS';if(DeptCode == 20) event.value = 'Finance';if(DeptCode == 30) event.value = 'Purchasing';// etc.

And there are other ways involving an array to load the combo box with the literal and value and then either going through the array using the code to locate the row in the array or use the 'currentValueIndices' property.

George Kaiser

shawnash
Registered: Dec 16 2009
Posts: 48
Thank you very much! :)

This is exactly what I needed...
cwparks
Registered: Apr 2 2009
Posts: 36
gkaiseril wrote:
You can use a custom JavaScript calculation script in the text field to add the value of combo box.
event.value = this.getField('Combo Box1').value;
Thank you SO MUCH for this code -- it's EXACTLY what I needed to make uneditable header fields that repeat user-entered text!