SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add a button for my users to clear a multiselect lookup value using JQuery or Javascript.

I have found some information about setting a default value on a single select lookup, but not the opposite.

I believe I can get the field using get_item("field name"). Is there a built in method for removing selected items?

Thanks, Patrick

share|improve this question
up vote 3 down vote accepted

Clear it? Would it be good enough to just move the items back to where they came from, by selecting them on the right side and clicking the button.

Something like this:

$('.ms-formbody').filter(function() {
  return $(this).html().match(/spfieldlookup/i) && $(this).find('select').size() >= 1;
}).each(function() {
  var $btn = $('<button>').text('Clear');
  var $select = $(this).find('select:last');
  var $remove = $(this).find('button:last');
  $ {
    $select.val($select.find('option').map(function() {
      return $(this).val();
    return false;
share|improve this answer
thanks for the reply, I'm trying to understand how this works. So you collect all lookups in an array, reference the button on the page that has the text 'Clear', then for each field, it selects all the selected options, then removes them? Is that correct? – hrezs Sep 25 '12 at 17:14
Yes. Essentials by lines: 1-3: select all SPFieldLookupMultis (not all are called multi actually, so you need the size-check of 'select'. 4: Create your clear-button. 5: right-side select. 6: the "< Remove"-button. 7: When your button is clicked. 8-10: Choose all possible options in the right-side select. 11: Click the "< Remove"-button. 12: Prevent propagation. 14: Add your clear-button to .ms-formbody – eirikb Sep 25 '12 at 17:51
awesome, thanks for your help! – hrezs Sep 25 '12 at 18:36

Your Answer


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.