2019-07-27 05:18
浏览 108


I am having 2 dependent dropdowns. Second one is depend on first dropdown. I am using onchange event to get data in second dropdown with ajax call.

below is my 2 dropdowns and ajax call :

first select box:

<select name="cust_type" id="cust_type"  class="cust_type" 
    onchange="getCustomersByType(this.value);" > 
    <?php echo $customer_type;?>

Second select box:

<select  name="CompanyName[]" id="CompanyName" multiple  class="customer_name" > 

ajax call :

function getCustomersByType(value)
            var getCust = $('#cust_type').val();

            var customer_type = value;
                method: "GET",
                dataType: 'json',
                            $.each(data, function(index, value) 
                                    $("#CompanyName").append('<option value="' + value.CUSTOMER_ID + '"'  +
                                    '>' + value.CUSTOMER_NAME+ '</option>');


my data is proper. I am able to change my second dropdown with change on first. But when i am using multiselect plugin with checkbox for multiselect second dropdown failed to change data.

Below is code for multiselect :

        columns: 1,
        placeholder: 'Select Com',
        search: true,
        selectGroup: true,
        selectAll: true,
        maxPlaceholderOpts: 0,

please help me with this to empty select onchange first dropdown and show data.

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyi1909 2019-07-27 05:35

    Use reload method to display the new options after populating.

    点赞 评论

相关推荐 更多相似问题