The drop-down box displays only the values in the initial drop-down box and the JSON returns the intersection of the array

Source: Internet
Author: User

First we can traverse dropdown

var array = new Array ();

$ ("#select option"). each (function (j) {

array[j]=$ (This). Val ();
$ ("#select option[value=" +this.value+ "]"). Remove ();
});

The values in the drop-down box are stored in an array and then move, and then compared to the array in JSON

for (var i = 0;i<accountnoarr.length;i++) {
for (Var k=0;k<array.length;k++) {
if (Accountnoarr[i].accountno==array[k]) {
$ ("#Select "). Append ("<option value= '" +array[k]+ ">" +array[k]+ "</option>");
}
}
}

Put the same append in the Select.

var temp = "AA";

$ ("#select option"). Filter (function () {
return $ (this). val () = = temp; The value of option for select is equal to Temp (AA).
}). Prop (' selected ', true). Text ();

This is directly the description of the Select.

The drop-down box displays only the values in the initial drop-down box and the JSON returns the intersection of the array

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.