Skip to content Skip to sidebar Skip to footer

How To Dynamically Populate Options On Dropdown Lists Based On Selection In Another Dropdown?

I have a table which has the information of a category, say a product. I have listed them in a dropdown menu. Now, what I need to do is, list the sub category of the selected categ

Solution 1:

You should use AJAX.

With jQuery it is very simple:

$('#select1').change(function(){
$.ajax({
   //Send to php script category id. This script returns all subcategories
   $.ajax({
      type: "POST",
      url: location.href,
      data: data,
      success : function (data)
      {   
         // Your return categories in data// Append list options to select2
      } 
});
});

Post a Comment for "How To Dynamically Populate Options On Dropdown Lists Based On Selection In Another Dropdown?"