CF8 setting a dropdown value via javascript

Set a dropdown value via JavaScript in ChronoForms.

Overview

The dropdown element uses custom divs instead of standard HTML select elements, preventing direct JavaScript value assignment.
Place the form fields inside a Container with a Listener that Reloads on dropdown change, but note this may interfere with redirect buttons by adding output=ajax to URLs.

Answered
ChronoForms v8
pi pimh 20 Dec, 2025

Hi all, 

I need to fill a large number of fields in a form depending on one first dropdown element. To be more complete a user, can have multiple records saved to a database. He can visualize them all, and go to a modify page, select one of them, get the current values in the form fields, modify them and then save it back to the database.

To do this I now created a dropdown and added a onchange event via html parameters. After this I can set all fields via javascript whenever the user chooses another record. However I fail to do this for a dropdown element. Appearently it does not use the default html select type with options, but some divs.

So my question how can I set a dropdown element via javascript? Or is there another way to get this to work. Doing a submit and reading a single record is not preferred due to other aspects in the form. 

Any help appreciated. Pim

Max_admin Max_admin 20 Dec, 2025

Hi Pim

You can put your fields inside a Container and add a Listener to that container and Reload it on the dropdown change, I think that may do what you need

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
pi pimh 21 Dec, 2025
Answer

Hi Max, 

Tried this, but fails as well for a totally different reason. The solution indeed can handle my situation, however I also have buttons to do redirects and those will fail afterwards. The url is no extended with a output=ajax, causing redirects to load the new page without the exterior. Only the innerpart is returned. 

I have chosen to for now forget the option requiring the dropdown to keep it easy for myself and also because it had some other implications on my side to deal with such changes outside the website. 

So for others, yes the solution works unless you use redirects nextpage events elsewhere on your page.

It would be nice if there is a method to remove redirect parameters earlier set. It is more often an issue in my cases. 

Kind regards,Pim

Post a Reply