Populate A Box With Another November 13, 2022 Post a Comment --select class-- --select subject-- Solution 1: You could subscribe to the change event of the first select box and then trigger an ajax request to your server by passing the selected value. Then in the success callback of this request you could use the JSON array returned by the server to update the contents of the second select box. Here's an example of how to achieve this using jQuery: $(function() { $('.class').change(function() { // when the value of the first select changes trigger an ajax request var value = $(this).val(); $.getJSON('/script.cgi', { selectedValue: value }, function(result) { // assuming the server returned json update the contents of the // second selectbox var subject = $('.subject'); subject.empty(); $.each(result, function(index, item) { result.append( $('<option/>', { value: item.value text: item.text }) ); }); }); }); }); Copy and the JSON returned from the server could look like this: [ { value: '1', text: 'subject 1' }, { value: '2', text: 'subject 2' } ] Copy Share Post a Comment for "Populate A Box With Another"