Welcome Guest, Not a member yet? Register   Sign In
Required Ajax Dropdown to fetch Categories & subcategories both from Database
#1

[eluser]Unknown[/eluser]
Hi Guys,

I would be really thankful if you can tell me how to fetch categories and associated sub categories in drop down from database without Page Re-load (using ajax).

I have a categories drop down in which i have fetched all categories from table : categories

Now, what I want is that when a user selects a category, subcategories should be displayed in drop down in which all the subcategories would be coming from table against selected category id. I need to implement this in CodeIgniter.

PLEASE HELP!
#2

[eluser]Ben Edmunds[/eluser]
There are several ways of doing this.

The way I would choose is to do an ajax request [.request()] with the chosen main category to a controller that interacts with a model and return the sub-category items.

If you are using JQuery then the function is ajax(). If you are using something other than JQuery just research AJAX request with whatever your using, whether that be straight javascript or another framework.
#3

[eluser]mattpointblank[/eluser]
To make it slightly quicker, you could display all of the subcategory dropdowns, use javascript to hide them on page load, then show the relevant one when the user selects an option from the category list.




Theme © iAndrew 2016 - Forum software by © MyBB