I want to generate State – District dropdown multi select dropdowns in WordPress.. According to the selections of States, Districts has to be loaded..
Please suggest me if there is available any plugin..
I want to generate State – District dropdown multi select dropdowns in WordPress.. According to the selections of States, Districts has to be loaded..
Please suggest me if there is available any plugin..
You must be logged in to post a comment.
I’ve recently written a blog post about this: http://bdwm.be/how-to-create-dynamically-populated-cascading-dropdown-lists-for-contact-form-7/. This example is with cars, but I applied to your case it would look something like this:
You could start with a CSV file containing all the states/districts, like this:
save it as states_districts.csv and place it somewhere on your server. (In this example I placed it in the wp-content/uploads folder)
Then using the contact form 7 plugin create 2 select fields:
Next, create some javascript in your page’s footer, that will perform an AJAX call
Finish up by creating your server side function that will read in the CSV file and return the correct values to the javascript:
add this to functions.php:
I want to share a fix for anyone that is trying to use this code.
There is a mistake in line:
it should be
Where do you wish to use the drop downs ? In plugins or in themes or just in page ?
This can be done using Ajax calls. In general, you should register a Ajax call handler in plugin/theme and add your dynamic dropdowns in your page.
http://codex.wordpress.org/AJAX_in_Plugins
jQuery is embedded with WordPress, check this section on how to create dynamic dropdown
http://www.jqueryscript.net/demo/Dynamic-jQuery-Cascading-Dropdown-Lists-Plugin/