Link to home
Start Free TrialLog in
Avatar of Isaac
IsaacFlag for United States of America

asked on

Multi Select Option

I have a SharePoint jquery form that I use in a CEWP and one of the elements on the form is a Multi Selecion element, which is a drop down list that allows for multiple selections.  Ex:

<select name="cars" multiple>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

The element needs to be pre-selected with data from a SharePoint list.  I have a column called cars and the data is comma dilimited (Saab,Audi).

So, using spservices and jquery, how do I pre-select the element with "Saab" and "Audi"?

Thanks for any help or insight you can provide.
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

$(function() {
	$('select[name="cars"] option[value="saab"], select[name="cars"] option[value="audi"]').attr('selected', 'selected');
});

Open in new window

Avatar of Isaac

ASKER

That didn't work...Here it is in jsfiddle:

http://jsfiddle.net/rXGmc/
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial