Updating select box using ajax

To avoid having to write and append HTML and stick with a more Javascript approach the new option can be appended with j Query by creating a new option object.

This next example does not work correctly in Internet Explorer; it will add the new option but only the value and not display any text.

I already placed the field for listing state, only want to load the values from ajax. whenever I submit form it shows state (field loaded by ajax) is ' An illegal choice has been detected. How can I update the new option values of field state which I have loaded from ajax call to the drupal form. This would normally be * pulling data from the database.

function mymodule_country_state_city($form, & $form_state, $no_js_use = FALSE) function ajax_example_dependent_dropdown_callback($form, $form_state) function ajax_example_dependent_dropdown1_callback($form, $form_state) /** * Helper function to populate the first dropdown.

Firing and handling the AJAX request is a frontend task, but as I understand you, fetching the options are backend stuff.

Last modified 15-May-2015 19:24