combined 2 arrays in select box Jquery chosen.js

2019-06-07 05:44发布

问题:

I'm using chosen js for my select field.

please check below code.

1> below input box list shows the emails which coming through checkbox selection

for (var x in email_list) {
    var selected_email = email_list[x]['email'];
    output +=   '<input type="text" style="" class="groupCheckBox" name="email[]" value="'+selected_email+'">';
}

2. below is my chosen,js integrated multiple select box. which loads all the emails in db,

var all_emails = json_obj['userEmails'];
output += '<select data-placeholder="" class="chosen-select" multiple style="width:100%;" tabindex="4">';

for (var el in all_emails) {
    var all_emails_lists = all_emails[el][0];
    output +=   '<option value="'+all_emails_lists+'">'+all_emails_lists+'</option>';
}
output += '</select>';

What I want is to combined these two into one , to show the first items as selected items in 2nd select box. and hide those from autocomplete unless the unselect it.

Please advice how to proceed.