Hi,
The following code will not work for me in ie6 but unsurprisingly, it does work in every other browser:
$('#myDropdown').val('value');
I have no idea why this is happening.
Any thoughts?
Paul
Hi,
The following code will not work for me in ie6 but unsurprisingly, it does work in every other browser:
$('#myDropdown').val('value');
I have no idea why this is happening.
Any thoughts?
Paul
You probably need to do something like
$("#myDropdown > option[selected]").removeAttr("selected");
$("#myDropdown > option[value='value']").attr("selected","selected");
Just a guess.
I ended up having to set the innerHTML of the select.
I came up with the following extension method that has a special routine for IE6:
$.fn.setDropDownValue = function(valueToSet) {
if ((!this[0].options) || (this[0].options.length == 0))
return;
if ($.browser.msie && $.browser.version == 6.0) {
var open = '<OPTION value=\'';
var html = '';
for (var i = 0; i < this[0].options.length; i++) {
var opt = $(this[0].options[i]);
html += open + $(opt).val() + '\'';
if (opt.val() == valueToSet) {
html += ' selected';
}
html += '>' + opt.html() + '</OPTION>';
}
$(this).html(html);
} else {
this.val(valueToSet);
}
};