Have a potentially infinite collection of drop downs, giving them all the same class, need to be able to access, loop through, and collect the selected value on the option of all the drop downs regardless of how many there could be. The final form should be something like 5,6,7,6,4,2,3,4,3,4 as a comma delimited list of the selected values from all drop downs.
Have a potentially infinite collection of drop downs, giving them all the same class,
Share
To explain what that’s doing:
map()method;join()function transforms that array into a comma delimited list.For example:
first uses
$()to construct a jQuery object of the selected options (2, 3 and 5), maps the value attributes into an array of{2,3,5}and then joins them into a comma-delimited string"2,3,5".