This time we are taking a look at the multiple select lookup fields in SharePoint. You get a field like this when you create a new lookup column, and check the “allow multiple values” box in the additional column settings.
It looks so tiny: we got a line with 2 select boxes and 2 buttons in the edit page:Behind it however, there are a lot of code lines: a few hidden input fields, a table, a select and ALL your data.
So what if your lookup lines are rather long ? After a close inspection of all the stuff that is there, you can see there are 2 select fields that actually matter. And to make things easy for us (thank your Microsoft), they even have really nice names as well:
The first one, which holds the list of possible values, has the title: “your field name possible values”. In our example here, the title is: “multiple lookup possible values”.
The second one, which holds the list of selected values, has (can you guess it already?) the title “your field name selected values”. In our example here, the title is: “multiple lookup selected values”.
This makes it very easy to grab the components and do all kinds of kinky things with it.
Code for setting the width:Important: for this to work, the setting “Launch forms in a dialog” in advanced settings has to be set to “no”. Make sure you link to the correct jquery file.
If you want to grab all multiple lookup fields in SharePoint page at once, you can use: