1

How can i set the value of sharepoint form field dropdown box(lookupfield) in sharepoint list form when the form gets saved (using jquery) note: the lookupfield (dropdown formfield renders as input if it contains values more than 20)

2 Answers 2

2

I just implemented such a solution a couple of weeks ago

Here is a very good post that will explain all.

0

So I have a field called "Data Classification":

var dataClsField = $('select[title="Data Classification"]');

I was trying to set this field with the value of another dropdown called "DataClass" that I got using this code:

var clsFieldValue = $('select[id*="DataClass"] option:selected').val();

For some crazy reason, I had to do both of these options to get my first field to set right:

dataClsField.find('option[value="'+clsFieldValue+'"]').prop('selected', true);
dataClsField.val(clsFieldValue.val());

Note: This was with 2 dropdowns with less than 20 items in each. I believe the only difference, jQuery-wise, when it goes over that, is that "select" becomes "input" on your selector.

Your Answer

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

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