ok, first off this works in FF, Chrome and Safari, but does not work in IE.
- What I am doing is converting the complex dropdown to a simple dropdown using SPServices
- Auto-populating the projects column with a querystring parameter
Here is the code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/jquery.SPServices/0.7.1a/jquery.SPServices-0.7.1a.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$().SPServices.SPComplexToSimpleDropdown({
columnName: "Project"
});
function getQuerystring(key, default_)
{
if (default_== null) default_="";
key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var qs = regex.exec(unescape(window.parent.location.href));
if(qs == null)
return default_;
else
return qs[1];
}
var proj = getQuerystring('proj');
//var list = document.getElementById('ctl00_m_g_dd8909e5_25f4_49a8_b1d6_229952d5ab91_ff101_ctl00_Lookup');
$('#ctl00_m_g_dd8909e5_25f4_49a8_b1d6_229952d5ab91_ff101_ctl00_Lookup option:contains(' + proj + ')').attr('selected', 'selected');
if($.browser.msie){
//var list = document.getElementById('SPComplexToSimpleDropdown_Project');
$('#SPComplexToSimpleDropdown_Project option:contains(' + proj + ')').attr('selected', 'selected');
var selectedVal = $('#SPComplexToSimpleDropdown_Project option:contains(' + proj + ')').val();
alert(selectedVal);
//set the complex dropdowns value
$('#ctl00_m_g_dd8909e5_25f4_49a8_b1d6_229952d5ab91_ff101_ctl00_ctl01').val(selectedVal);
}//end if
});
</script>
Again, it works great, accept in IE. I know that the problem lies within assigning the value to the sharepoint complex dropdown. but now sure how to set that.