we have a list for travel schedules. We have a dropdown for Monday to Friday then individual mulitselects for each day. i am trying to use the following code to auto populate the selected item for each day.


    var fill= $('#Monday_x0020__x002d__x0020_Frida_1922e8b2-788e-47ee-a1f8-5920062dd680_\\$LookupField option:selected').val();
    var dTitle = $('#Monday_x0020__x002d__x0020_Frida_1922e8b2-788e-47ee-a1f8-5920062dd680_\\$LookupField option:selected').text();
    var dest = ('<option value="'+fill+'" title="'+dTitle+'">'+dTitle+'</option><option></option>');


the code works for populating the "Selected Values" boxes but when I post the form the values do not post. If I use ie dev tools and refresh the dom after auto populating the fields they show up in dev tools but still do not post.

Oddly if I add another selection to a day (as they are multiple select boxes) both values will then be posted.

I put the code into a Context Editor in the default new form. jquery is being loaded I just left out those calls here.

we are on SharePoint 2010

Any Ideas?? Thanks


There are hidden fields that hold the actual value of the fields in the list.

In dev tools, $("[id$='MultiLookup']").val() returned the value "2|tTest2|t3|tTest3" for

<option value="2" title="Test2">Test2</option>  
<option value="3" title="Test3">Test3</option>

Reference: http://weblogs.asp.net/bsimser/defaulting-values-in-a-multi-lookup-form-in-sharepoint

| improve this answer | |
  • That was it. I just added values to that hidden field and it worked. The selected values from the auto fill now save to the list. – KurtH Jun 11 '15 at 12:34

I think you're missing a $:

var dest = $('<option value="'+fill+'" title="'+dTitle+'">'+dTitle+'</option><option></option>');

Why not clone the selected option and then append to the other selects?

        var selected = $(this).find("option:selected");

| improve this answer | |
  • Same result. The fields are filled in but they don't post through. – KurtH Jun 10 '15 at 19:32
  • When you say "posted" you mean not saved to the list, right? Anyway we could get a few screenshots to help us visual people? – IMTheNachoMan Jun 10 '15 at 20:26

You need to add the selected attribute to the option element:

var dest = ('<option selected value="'+fill+'" title="'+dTitle+'">'+dTitle+'</option><option></option>');
| improve this answer | |
  • Should have mentioned I already tried that both selected and selected="selected". Neither worked. – KurtH Jun 10 '15 at 19:38

A lot of people are saying the fields are set but they don't post when saved. That's because you need to set the related hidden field. I posted a solution here:

set multiselect lookup column using jquery

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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