Dropdown populate using Codeigniter and javascript

Suppose you are building a Registration form in which users want to select a city to lives in. For that you need to populate respected state that person lives in, otherwise the city field will be extremely long (and there is more of a chance for user mistake and mystification). To solve this problem we need to create dynamic needy dropdowns. In order to accomplish this using Code Igniter, this is what I did:

Html view form dropdownpopulate.php

Now I will create database table for state and cities dropdown populate.

READ  Jquery popup slider using codeigniter.

This code was put into a code igniter view file called “dropdownpopulate.php”.
Now we add form open and closing form tags, and looks to a controller.
Here in the controller we will create a function to load the view file.
To load the states dropdown, we need to create model function get_state_info() to load the states information to controller file named as “ektree.php”.

Here I used JavaScript on select function to load city dropdown
In script I posted the state value to controller and print the out to html view file.

READ  How to import data from csv to mysql with php codeigniter?

Now I will create model functions to get the state and cities details.

Thanks for reading this article.

One Response

  1. Shafeer Khan March 31, 2018

Leave a Reply