![]() |
dynamic fetch of data - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: dynamic fetch of data (/showthread.php?tid=66557) |
dynamic fetch of data - sheenam - 11-04-2016 hi all, i want to fetch data dynamically from database using ajax call with one select and other autofill using ajax call i am unable to my code is like this: VIEW PHP Code: <?php include_once "vwHeader.php" ?> PHP Code: MODEL: CONTROLLER: PHP Code: <?php i am stuck please help me with this..thanku so much in advance. RE: dynamic fetch of data - dave friend - 11-04-2016 It would be helpful if you would edit your question and include the javascript that makes the ajax call. RE: dynamic fetch of data - Wouter60 - 11-04-2016 Well, start with putting code in your view for the 2 select lists that you want to use. I can't find any. Use <select></select> as surrounding html tags. The selectable options are created with <option></option>. Make sure they both have a name and an ID. The select lists must be inside <form></form> tags. Make sure jQuery is loaded in the head section of your view. At the bottom of the view, put the javascript code that makes the Ajax call. The trigger for that is a change in your first select list. Let's say this has the ID "categories", and you want to fill the list with ID "products" dynamically. The Ajax call could look like this: PHP Code: <script> In your controller, you collect the records from your database that have the selected category to build the html-code for the second (dependent) select list. At the end of the function, you echo that as a string: PHP Code: public function search() On more tip: never include a view inside another view with the php command "include". In CI you can nest views simply with: $this->load->view('view_name'); RE: dynamic fetch of data - sheenam - 11-04-2016 thanku so much for your replies. let me try. if stuck plz help me get through. thanu so much once again. |