populate select from other select value using jquery

前端 未结 4 1241
遥遥无期
遥遥无期 2020-12-02 02:53

hi all I have seen many question but no one has fulfilled my thirst. I want to populate select on the basis of one other select. I am using zend framework. I have a select t

4条回答
  •  感情败类
    2020-12-02 03:07

    You need to bind a change event for your first dropdown. Then in that dropdown you need to call an ajax function to your php page, which will give you the new selection for your 2nd dropdown. and on the first dropdown's ajax success function you will populate the 2nd dropdown.

    For ajax calling you can see http://api.jquery.com/jQuery.ajax/

    Sample:

    
    
    
    
    $(document).ready(function(){
        $('#ddl_account').change(function(){
           $.ajax({
              type: "POST",
               url: "account.php",
               data: "account=" + $(this).val(),
              success: function(options){
                //options = ""
                $('#ddl_account_2nd').empty().append(options);
              }
            });
        })
    
    })
    

提交回复
热议问题