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

Would somebody please verify that this JS works and suggest why its not working for me?

digitalwiz
Registered: Mar 9 2011
Posts: 20
Answered

I 26 posts deep on another thread and am hoping some fresh eyes/ideas might help resolve this issue.
 
Based on the JS Keystroke below...
 
1 combo box, 1 text box.
 
I pasted the following into the combo box--> format-->keystroke
 
// Custom Keystroke script for combo box
(function () {
 
if (!event.willCommit) {
 
// Set up an array of addresses. \r = carriage return
var aAddr = [];
aAddr[0] = "1721 13th Street\rSacramento, CA 95814";
aAddr[1] = "3500 Industrial Blvd.\rWest Sacramento, CA 95691";
aAddr[2] = "3310 El Camino Ave.\rSacramento, CA 95821";
aAddr[3] = "901 P Street\rSacramento, CA 95814";
aAddr[4] = "1416 9th Street\rSacramento, CA 95814";
 
// Get the export value of the selected item
var ex_val = event.changeEx;
 
// Get the corresponding address
var addr = aAddr[ex_val];
 
// Populate the text field with the address
getField("locationDetails").value = addr;
}
 
})();
 
I named my text box "locationDetails" without the quotes.
 
I added 4 value items for my combo box
 
CSA with ev of aAddr[0]
IT with ev of aAddr[1]
HR with ev of aAddr[2]
CM with ev of aAddr[3]
 
all the text box says is "undefined".
 
anything obvious that im doing wrong?

thanks

My Product Information:
Acrobat Pro 9.4.2, Windows
George_Johnson
Online
Expert
Registered: Jul 6 2008
Posts: 1875
Accepted Answer
The export values should be 0, 1, 2, 3, not aAddr[0], etc.
digitalwiz
Registered: Mar 9 2011
Posts: 20
That was it. thanks George.

I believe using this syntax I should be able to add the rest of the fields and field texts to my document.

thanks