I have multiple options in a select. I have sorted the options and disabled and hidden the duplicate options with jquery. The code works well in chrome and firefox but in IE
my 2 cents worth on an "old question", yet still a relevant issue.
Server side:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ //load subDropDownList all possible values [with an attribute for filtering] }
}
Client-side:
var optionList = null;
$(function(){
if (!optionList)
{
optionList = new Array();
$("[id$='subDropDownList'] option").each(function () {
optionList.push({value: $(this).val(), text: $(this).text(), filterID: $(this).data("filterid") });
});
}
$("[id$='mainDropDownList']").on("change", function (e) {
var filterID = $(this).val();
$("[id$='subDropDownList']").html("");
$.each(optionList, function () {
if (this.filterID == filterID)
$("[id$='subDropDownList']").append($("").val(this.value).html(this.text).data("filterid", this.filterID));
});
});
})
The idea here is on client side I load all values into an array, then on change event of the main select I add only the required options. Hope someone finds this helpful.