if you had:
<select id="Users" selection="multiple">
<option value="1">Bob</option>
<option value="2">Doug</option>
<option value="3">Jake</option>
<option value="4">Steve</option>
<option value="5">Mike</option>
<option value="6">John</option>
<select>
//values from database in some enumerable object
var vfdb = new Array("1", "4", "6");
//loop and set
var lst = $("Users")[0];
for (var i=0; i < lst.options.length; i++) {
for (var j=0; j < vfdb.length; j++) {
if (lst.options[i].value == vfdb[j]) {
lst.options[i].selected == true;
break;
}
}
}
of course that could be included in the success callback of some sort
of $.ajax call or whatever
On Sep 30, 9:51 am, "Allen Schmidt" <allen...@gmail.com> wrote:
> Greetings,
> If I have a select multiple set up with say 10 items, and I am making a pass
> over them from a call to a database that returns some of those values (more
> than one), how can I check to see if an option in the select is one of the
> items returned from the database and select it also?
> Thanks!
>
> Allen
No comments:
Post a Comment