How to dynamically populate options on dropdown lists based on selection in another dropdown?

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
      } 
});
});

Leave a Comment