This project has moved and is read-only. For the latest updates, please go here.

SPComplexToSimpleDropdown - Default value not taken into account

Feb 11, 2014 at 4:20 PM

I have implemented (what I thought was) a fantastic tweak on SP 2010 using SPServices, but it seems there is a bug.

I have 2 Lists:
  • Trainings
  • Enrollments (which contains a lookup field: Training, from the list above)
I am calling the Enrollments NewItem form, with a parameter in the URL (the ID of the training), and I use the parameter to pre-select the corresponding value in the dropdown list. In order to achieve this, I have found no other way than to overwrite the default dropdown by using SPComplexToSimpleDropdown.

The code is integrated in a separate html file, and included in the form via a Content Editor.

It is working fine. Or so I thought.
<script type="text/javascript">
    $(document).ready(function (){
        var selects = $('.ms-lookuptypeintextbox');
        if (selects.length > 0) {
            $(selects).each(function(index, value) {
                    columnName: $(this).attr('title') 

    document.getElementById("SPComplexToSimpleDropdown_Training").value = GetURLParameter('Training');

    function GetURLParameter(sParam)
        // this function works and is out of context
Here's the catch:
  • if I change the value of the dropdown, the value is saved OK;
  • if I leave the default value, however, the item is saved with a wrong value, as if it was taking into account the value of the "actual" (hidden) SP Dropdown instead of the visible one.
Do I need to trigger an additional event for this to work?
any info welcome. I hope my request is clear and hasn't already been answered elsewhere.

FYI I am running jQuery 1.7.2 and SPServices 0.7.1a

Have a nice day,
Feb 12, 2014 at 12:51 AM
Try adding a .change() event to the SELECT element after setting its value from the URL value. That ahould trigger Marc's code to the set the value of the 'real' value. Here is the code using jQuery:

.val( GetURLParameter('Training') )


Paul T.

-- Sent from Mobile

Marked as answer by hubertvdm on 2/12/2014 at 1:16 AM
Feb 12, 2014 at 9:16 AM

thank you!