Expand my Community achievements bar.

Java Script for Radio Button to distinguish selectible choices from a drop down list

Avatar

Former Community Member
Hello everyone, I have a two radio buttons on page one, each representing a distinct choice. On the next page I have a drop down list which populates a text field of choices selected from the drop down list (no problems there). What I need to do is to limit the choices of the drop down list selections based upon which radio button is selected in the previous page. So I would gather that I am in need of a java script that can enable this function, can anyone help?
5 Replies

Avatar

Level 7
The exact code will depend if you are using Acrobat Forms or LveCycle Designer. In Acrobat Forms you can use the "setItems(oArray)" method of the field object to set all the items in the combo box or list box. For LiveCycle Designer, you first must clear the drop down box or list box with the "DropDownList1.clearItems()" method and then use the "DropDownList1.addItem(.....)" to set each individual item to the drop down list or list box.

Avatar

Former Community Member
I am using Adobe LiveCycle Designer. If I understand you correctly are you saying that in the radio button, under "change" I should add in the following java script?



DropDownList1.clearItems(item1, item2, item3); DropDownList4.additem(item2, item3);



This is a guess as I am not sure of the syntax...am I close?

Avatar

Former Community Member
Typr error, I meant to say...



DropDownList1.clearItems(item1, item2, item3); DropDownList1.additem(item2, item3);

Avatar

Level 7
Assuming your drop down list is named "DropDownList1":



// clear the drop down item list

DropDownList1.clearItems();



// add items to the drop down list

DropDownList1.addItem("item2");

DropDownList1.addItem("item3");



LiveCycle Desinger only adds one item at a time.



You might want to read the "Scripting Help" under the "Help" menu bar item. It has examples for each property and method.

Avatar

Former Community Member
The script works good, thank you. However I neglected to mention that the drop down list, along with a text field are embedded into a subform. Hence the script does not work while the drop down list is in the subform. Can you please provide me with a modified script to give me the same effect as your previous post?