1

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 category in a next dropdown menu. I hope, javascript is required, but I am not that familiar with javascript yet.

Would be much thankful for the help.

1

1 Answer 1

3

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
      } 
});
});
Sign up to request clarification or add additional context in comments.

1 Comment

should that first $.ajax be there?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.