Hi everyone,

I have a multiple select menu where each option has a numerical value
attribute relating to a database ID, and I need to get the value of each
selected option element to join into a string. The current DOM attribute
functions all seem to operate on the first element of a jQuery result
set, but what about "plural" functions that would return an array of the
requested attribute values from all of the elements? Something like:

$('option:selected').vals()

Might produce:

[4, 56, 1]

Or:

$('option:selected').texts()

Might return:

['Option label 1', 'Option label 3', 'Option label 4']

Thoughts? My current implementation is something like this:

var ids = [];
$('option:selected').each(function() {
    ids.push(this.value);
});
alert( ids.join('/') );

Interestingly enough, the text() function will return a string of each
element's text, but cat'd together like "Option label 1Option label
3Option label4".  

m.

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to