Sometimes it is nice to present a multiple select listbox to a user with everything already selected.
Handy if you’re using listboxes as filter controls, and something that is, as per usual, quite easy to do using the magic that is the jQuery javascript library.
Essentially what the aim of the game here is to set the selected option in each of the multiple select listbox’s <option> entries. In order to do this, we will once again make use of jQuery’s nifty attr() function and apply this to the result of our clever little jQuery selector call, which will hone in on our desired select listbox using its ID value and then extending that result to only include all option entries.
So the resulting call would look something like this:
$("#multipleselect option").attr("selected","selected");
And there you go. A multiple select listbox with everything already selected for you!
Related Posts :
Grabbing all the selected values or even text values from a multiple select listbox turns out to ...
I've said it once and I'll say it a million times over and again, the jQuery javascript library ...
Multi-select boxes are wonderful creatures in that they provide a particularly easy to implement ...
There are a number of ways to set the selected index of a dropdown list when it comes to jQuery, ...
To change the selected value, or selected index if you will, of a dropdown list using jQuery is ...






