Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

How to link Radio Button with Drop-down List ?

Avatar

Level 1

I have 2 Radio Button (IT and Business) and a Drop-down List (Course Title).

I need the list item to change when I choose the Radio Button, so if I choose (IT) the drop down list should contain (Introduction to Programming, Algorithms & Datastructures), and if I choose (Business) the drop down list should contain (Marketing Managment, Financial Accounting).

can you help me?

Thanx

3 Replies

Avatar

Level 10

Hi,

Yes, this is possible with a little bit of script.

Here is an example using checkboxes: https://acrobat.com/#d=cS2B8Nj17CFbw1D9-BAnQA

The trick is to have the script in the preOpen event of the dropdown. This would look at the value of the radio button exclusion group and based on the selection, the script would populate the dropdown list with the appropriate items, JUST in time.

So if the radio button exclusion group was called department and IT had a specified value of 1 and Businesss was 2 (see Object > Binding palette), then the following javascript should work in the preOpen event:

// clear the dropdown displayed value and items

this.rawValue = null;

this.clearItems();

// repopulate the items based on the checkboxes

if(department.rawValue == 1)

{

     this.addItem("Introduction to programming", "Course_001");

     this.addItem("Algorithms", "Course_002");

     this.addItem("Data structures", "Course_003");

}


else if(department.rawValue == 2)

{

     this.addItem("Marketing management", "Course_004");

     this.addItem("Financial accounting", "Course_005");

}

else

{

     app.alert("Please select a department");

}

The above solution is based on not having items specified in LC Designer. The dropdown items are added at runtime. Also the bound item "Course_001" is optional.

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 1

Thanx alot Niall that was very helpfull.

here what I did :


in Drop-Down List preOpen state

this.rawValue = null;

this.clearItems();

if

(xfa.resolveNode("department.#field").rawValue == 1)

{

this.addItem("Introduction to programming");

this.addItem("Algorithms");

this.addItem("Data structures");

}

else if(xfa.resolveNode("department.#field[2]").rawValue == 2)

{

this.addItem(" management");

this.addItem("accounting");

}

else

{

app.alert("Please select the College first");

}

Thanx again

Avatar

Level 1

Thanx alot Niall that was very helpfull.

here what I did :


in Drop-Down List preOpen state

this.rawValue = null;

this.clearItems();

if

(xfa.resolveNode("department.#field").rawValue == 1)

{

this.addItem("Introduction to programming");

this.addItem("Algorithms");

this.addItem("Data structures");

}

else if(xfa.resolveNode("department.#field[2]").rawValue == 2)

{

this.addItem(" management");

this.addItem("111accounting");

}

else

{

app.alert("Please select the College first");

}

Thanx again