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

Javascript Cascading Combo Box

jrobbins
Registered: Dec 3 2009
Posts: 4

Let me start off by saying Thank YOU for anyone who replies! I am in dire need of this to work LOL.

Additionally; yes - I have looked at the tutorial where one combo box populates another; however that is much more complex than I need. I have tried multiple times to modify / make the script my own only to have an issue come up that I cannot seem to fix or find the solution I need online.

In short: I need to make two combo boxes where the second one is populated based on the selection made on the first. This must be manual - No SQL database linking etc...everything must live in the form through javascripting.

Example:
Combo Box 1 has the following items listed
Product Family1
Product Family2
Product Family3
Other

Combo Box 2 will be populated with a list based on the selection of the first.

MY ISSUE:
In testing the functions in adobe they work fine. I am uploading this form into a separate program for use as an electronic form. When the user makes a selection on combo box one, combo box two is populated with the correct list. I make the selection in combo box two and all appears well. I submit the form for review. On that approval step the value on combo box 2 is not what the value originally selected it is the hyphen at the top of the list. For some reason the value is not stickin on the second combo box.

I loaded the tutorial form:

http://www.windjack.com/PDFSamples/ListPrograming_Part1_AcroForm.pdf

To verify it was not the software that was causing my issue. That form works fine.

DOCUMENT LEVEL JAVASCRIPT ( I Call for the SetEntries function as a custom keystroke script on combo box 1):
var xProducts = {

ProductFamily1:
[
["-"],
["Product 1"],
["Product 2"],
["Product 3"],

ProductFamily2:
[
["-"],
["Product 4 "],
["Product 5"],
["Product 6"],

ProductFamily3:
[
["-"],
["Product 7 "],
["Product 8"],
["Product 9"],

Other:
[
["Other"]
]

};

function SetEntries()
{
// Only run this code on when the selection is commited.
if(event.willCommit)
{
var lst = xProducts[event.value];
if( (lst != null) && (lst.length > 0) )
this.getField("combobox2").setItems(lst);
else

this.getField("combobox2").clearItems();

}
}

My Product Information:
Acrobat Pro 7.0, Windows
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
I think the script gets executed when the file is submitted. You should have it as a custom calculation script, not a keystroke script.

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

jrobbins
Registered: Dec 3 2009
Posts: 4
Thanks for the Reply!

Well the weird thing is the linked form works just fine in the system and it is all done through custom keystroke.

what I think is going on is the scritp populates the field....allows the user to make a selection...but there is no value associated.

if you look at the example PDF...I think there is some thing that sets the value or makes combo box number 2 actually have a value because it has a keystroke script called "SetPriceValue" that combo box number 2 runs (where as i have not function called up on my combo box b/c i assumed that everything in SetPriceValue had to do with the price field and nothing to do w/ combo box 2) to populate the value of a text field type of thing but i dont see where that function makes the user selection become a value stored to combo box 2 *shrug*.

example / tutorial form has this function called up on the custom keystroke:

function SetPriceValue()
{
// Only run this code on the un-committed change. This fields is set up
// for Commit on select so we know the value will be committed
if(!event.willCommit)
{
var cRowName = event.target.name.split(".").shift();

// If the export value is Not a Number then
// set the price to zero.
var nSelExp = 0;
if(!isNaN(event.changeEx))
nSelExp = event.changeEx

this.getField(cRowName + ".Price").value = nSelExp;
}
}