• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Required Ajax Dropdown to fetch Categories & subcategories both from Database

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.


[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.

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.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.