Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a sharepoint list which where I want to insert multi selected values from a dropdown list.

<select multiple="multiple">
   <option>A</option>
   <option>B</option>
....
</select>

My question is can anyone show a sample code/idea how can I achieve it by using ecmascript?

share|improve this question
add comment

1 Answer

There are at least 3 types of selection based columns: 1. Choice lists (single value and multi-value) 2. Lookup lists 3. Managed Metadata 4. Custom multi-valued columns - most complex - won't fit really as it is too complex.

There is a difference in how you would need to read/store these values. For example for Lookup you would use SP.FieldLookupValue which shall return an array, as in

function onQuerySucceeded(sender, args) { var listItemEnumerator = collListItem.getEnumerator();

while (listItemEnumerator.moveNext()) 
{
var oListItem = listItemEnumerator.get_current();
var selItems = oListItem.get_item('SelectedItems');
var i=0;
  for(i=0;i<selItems.length;i++)
  {
    alert(selItems[i].get_lookupValue());
   }
}

}

See here a full example http://kamilmka.wordpress.com/2012/01/10/ecmascript-client-object-model-get-the-values-from-a-multi-select-lookup-column-field/

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.