• I’m creating a plugin and I have a cloned form with 2 selection boxes, both of these boxes draw their options from my database through php.

    The first one shows a list of countries and the second selection box will list all the universities that exist in the country selected in the previous selection (based on COUNTRY_ID).

    What I try to do is with the onChange to retrieve the country_id selected from the first select and use it to show the options of the second selection.

    I use the function in the script as bellow

    <script>
    
      $(function() {
          $('#table_university').on('change keyup', '.cnt', function(){
              
    		  var cnt = $('option:selected', this).val();
    		  alert(cnt);
    		  var uni ='wp-content/themes/mytheme/lib/cities.php?val='+ cnt+'&id=universities&func=0';
    		  $(this).next('.uni').val(uni);
    		 $('.uni').load(uni); 
          }).keyup();
    	  });
    	  
    */
    						  </script>

    This is worked in my theme but in the duplicated form it conserve the same options in the second dropdown and when I put it in the plugin its didn’t work.

    Any help will be appreciated. Thank you in advance

  • The topic ‘Show options of selection from database based on parent selection’ is closed to new replies.