Dynamic Dropdown

Flamingo 14d ago

I'm trying to accomplish the classic task of displaying the federal states for selection in a second dropdown field, depending on the country setting in the first dropdown. My first attempt using JavaScript failed because the option list created by the JavaScript was blocked/overwritten by the CF8 field. How can this be prevented? In a second attempt, I created the necessary option arrays from the database using PHP. I haven't found any way to pass these arrays to the dropdown field. How exactly should this be done? Is there a proven example for this task? Thank you very much for any help!

Flamingo 12d ago
Answer
1 Likes

Hi Max

Thanks for your feedback. I saw this suggestion. For this relatively simple purpose, it's complicated, and I don't understand how it works with multiple countries.

I've now solved the problem with one dropdown field per country. These are hidden or shown depending on the selected country using listeners. This is also complicated, but transparent and robust.

I can't recommend using JavaScript for this. You have to consider too many CF functions.

Max_admin 10d ago

Hi Flamingo

Showing/Hiding different dropdowns is also ok, but the solution in the FAQ is more dynamic

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Post a Reply