Unable to set val() of select in IE 8 using SPCascadeDropdowns or SPComplexToSimpleDropdown

Feb 21, 2015 at 7:38 PM
Hi there - I'm stuck, still, using IE 8 and SP2007. Fun! My code works in a modern browser but I can't get it to fly on IE 8 (and that's important).

Here is what I am doing, basically:
$().SPServices.SPCascadeDropdowns({
  relationshipList: "Staff List", 
  relationshipListParentColumn: "EmployeType2", 
  relationshipListChildColumn: "Title", 
  parentColumn: "Employee Type",
  childColumn: "Employee",
  simpleChild: true,
  debug: true
});

// some code that gets the current logged in user's info from another list:
  var spsUser = getCurrentStaffUser();

// trying to update the values on my form to match the user's values:
$('#employee_type_id').val( spsUser['EmployeType2'].lookupID ).trigger('change');
$('#employee_id').val( spsUser['ID'].lookupID );
This works fine in a modern browser! But in IE, only the Employee Type changes to the correct .val() ... the second one doesn't fire. I think it has something to do with the simple to complex drop down conversion ... I've tried even doing away with the $().SPServices.SPCascadeDropdowns and just using $().SPServices.SPComplexToSimpleDropdown ... but that still doesn't work in IE8.

Any insight?
Coordinator
Feb 21, 2015 at 11:29 PM
There's nothing here that shouldn't work in IE8. Time for the debugger!

M.
Feb 22, 2015 at 12:33 PM
Thanks for taking a look at it. I didn't even know IE8 had a debugger! Smile. I try to stay as far away from it as possible.

Back to work!
Feb 22, 2015 at 2:05 PM
Okay! So, it looks like I figured it out by searching for, and eventually come across, one of my own questions that I had posted years ago. Smile.

For others, who might find this it comes down to the fact that the "complex" dropdown that is available in IE has to be handled differently than the dropdown that is generated for other browsers. And by that I mean, in IE 8 the simpleChild or SPComplexToSimpleDropdown does some stuff that it doesn't have to do in other browsers. So, in IE8 you find the element at:

$('#SPComplexToSimpleDropdown_Employee')

That's why nothing was working in IE because I wasn't using that id; instead, I was doing what works in Chrome/Firefox (which doesn't use that complex dropdown stuff):

$('#ct100_m_g_etc_etc_etc$Lookup)

So, to get it to work in both browser types, I am now doing:
var $employee = $('#SPComplexToSimpleDropdown_Employee');
if ( !$employee.length ) {
  $employee = $('#ct100_m_g_etc_etc_etc$Lookup'); // 
}
Seems to be working now. Thanks to Marc and, in a round about way, myself, for the tip!
Coordinator
Feb 22, 2015 at 4:29 PM
Glad you got it! In all versions of SharePoint - even 2013 - IE acts a little differently than other browsers. For this reason - while you can build and debug in any browser - you simply have to do at least the last round of debugging in IE.

M.