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

SPComplexToSimpleDropdown and jquery cookie plugin.

Nov 14, 2012 at 8:57 PM

Im using SPComplexToSimpleDropdown on a list that is having its value set with a cookie.  The dropdown is being converted to a simple dropdown.  I can see that visualy. 

The code Im using is:

 columnName: "Equipment",
 debug: true

Once I started using the SPComplexToSimpleDropdown function, the cookie no longer works.

I relize that the Id has changed and have used the following code as the jquery selector to set the cookie. 

$('#SPComplexToSimpleDropdown_' + 'opt.Equipment').val(equipmentid);


Im assuming there is something wrong with my selector, but I dont see it.  I beleive I followed what was in the directions for the SPComplexToSimpleDropdown.


Can somebody verify that im correct? 



Nov 15, 2012 at 7:42 PM
Since you are not sure where the problem is let's check a few things. Do this after you set it to a simple drop down:

// check if the drop down was found. Should find 1
alert('Found select: ' + $('#SPComplexToSimpleDropdown_' + 'opt.Equipment').length );

// ensure we have a value to set
alert('select will be set to: ' + equipmentid)

On the last one check that the value you are setting is present on the dropown. Don't remember how Mark built the dropdown, but maybe you need the Title if you are using the ID of the lookup item.


Sent from mobile device.
Nov 19, 2012 at 2:43 PM

Thanks for the reply.

The first alert gave a "Found Select: 0".  So it looks like something is wrong there.


The last alert where you were testing the cookie is fine. 

Nov 19, 2012 at 3:26 PM
Edited Nov 19, 2012 at 4:43 PM

I think your original selector is incorrect. Try this.


If that doesn't work, then you should use the IE Developer Tools or Firebug to look into the DOM for the correct ID.


Nov 19, 2012 at 3:43 PM

That didnt work either.


IE Tools shows this as the ID, but using that as the selector dosent work either.

<SELECT id="SPComplexToSimpleDropdown_undefined" title="Equipment"

Nov 19, 2012 at 4:45 PM

Hmm. If the id is set to "SPComplexToSimpleDropdown_undefined", something's going wrong. The id ought to be "SPComplexToSimpleDropdown_Equipment". The id is build from the string "SPComplexToSimpleDropdown" plus the StaticName (not the DisplayName) of the column.


Nov 19, 2012 at 9:40 PM

Something is wrong but everything works if I use SPComplexToSimpleDropdown_undefined as the ID.  Not sure what to think.

Nov 19, 2012 at 9:45 PM

Well, that is indeed the id, so it ought to work. However, something's wrong in that SPServices is generating an odd id.

You may be fine carrying on with your selector for "SPComplexToSimpleDropdown_undefined", but something's not right for SPServices to generate that id.

What versions of jQuery and SPServices are you using?


Nov 19, 2012 at 9:49 PM

jquery 1.8.2.min

sp 0.7.2

Nov 19, 2012 at 9:52 PM

No idea what's going on, then. If you can do some debugging to find the error, I'd appreciate it. The function where the problem is occurring is genContainerId. I assume that your form page is in the list context? i.e., /sitename/Lists/listname or for a doc lib, /sitename/listname

Nov 19, 2012 at 10:33 PM

I guess it isnt working.  The cookie gets set, however when I submit the form the equipment field dosnet get anything saved for that field.  Its just blank.

Nov 19, 2012 at 10:45 PM



This is the actual path.

Thanks, Ill take a look at the function.


Nov 20, 2012 at 3:13 PM

If I change the code to force the ID I can make the new dropdown work.  Which is currently fine becasuse I only need this for one column right now.  I will continue to dig through the code to see if I can find the true issue though. 

// Build up the simple dropdown, giving it an easy to select id
  var simpleSelectId = 'SPComplexToSimpleDropdown_Equipment';

I can then set the value with the following cookie value.


When I go to save the form, the value from the newly created simple dropdown is blank.  If I manually change the option everyting gets submitted fine. 

Im setting two cookies in the form, and the first one gets saved just fine.  Only difference is its a simple dropdown from the start.


Any ideas on what I need to add to  $('#SPComplexToSimpleDropdown_Equipment').val(equipmentid);  to ensure it is in fact selected and the value will be submitted?

Nov 20, 2012 at 4:25 PM

You won't be able to manually change the id, because then the rest of the event binding in the SPComplexToSimpleDropdown won't work. Complex dropdowns have a bunch of hidden elements which actually are what is submitted. Those elements are populated via the event bindings.

The reason the id is ending up as SPComplexToSimpleDropdown_undefined is that your form isn't in the context of the list. Simply moving it into the list context ought to fix the SPServices issue.


Jan 24, 2014 at 8:54 PM
I ran into a similar issue on a publishing page where it returns the dropdown ID as "SPComplexToSimpleDropdown_undefined" in IE. Would it be possible to add a relationshipList or ListName argument to it?
Jan 25, 2014 at 9:57 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Jan 28, 2014 at 6:17 PM
Thank you! :)