javascript - Populate an array to consist of all of the values in an html select list using jQuery -


i have html select list (let's call list a) dynamically populated list of values. need change select list (list b) depending on value of list a. part, can do. ordinarily, user selects one element of list a, , gets list b contingent on list a.

however, first element of list "all values." therefore, in instance, want list b consists of aggregate of of values possible list b. because available values of list dynamically generated, can't pull list b values. need pull list b values contingent on list values shown.

to this, want iterate through of values in list a, , append list b each item in list a. i'm stuck. how can populate array consist of of values in select list? again, because list populated dynamically, way list of these values pull them select list element.

i tried this:

iterate_models = $.map($('#lista'), function(e) { return $(e).val(); }); 

this did not give me array of values of each element in #lista. can't figure out why not.

you need map val() on <option> elements in dropdown list:

iterate_models = $.map($("#lista option"), function(e) {     return $(e).val(); }); 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -