1

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?

1 Answer 1

2

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.