php dropdown menu population

后端 未结 4 1579
广开言路
广开言路 2021-01-01 08:31

I\'m trying to write a php script that will populate a second drop down menu based on the selection of the a primary drop down menu. I would like to use jquery to do all the

4条回答
  •  别那么骄傲
    2021-01-01 09:11

    Add one more line jQuery('#city').html('');
    Now the code look like :

    jQuery(document).ready(function() {
    
        jQuery('#state').change(function() {
    
              jQuery('#city').html('');   
              jQuery.post(
                    'some-url.php',
                    {
                            'state':jQuery('#state').val()
                    },
                    function(data, textStatus) {
                            jQuery.each(data, function(index, value) {
                                    jQuery('#city').append('');
                            });
                    },
                    'json'
            );
        });
    
    });
    

提交回复
热议问题