jQuery refresh dropdown

Oatman

New Member
I followed the examples to update a dropdown from the selection of another dropdown:\[code\] var pageUrl = '<%=ResolveUrl("~/Reports.aspx")%>'; function PopulatePortfolioDropDown() { var ddl = document.getElementById('<%=ddlPortfolio.ClientID %>'); ddl.options.length = 0; var prgyr = document.getElementById('<%= ddlProgYear.ClientID %>'); var agy = document.getElementById('<%= ddlAgency.ClientID %>'); $telerik.$('#<%=ddlPortfolio.ClientID %>').empty(); //.append('<option selected="selected" value="http://stackoverflow.com/questions/13879312/0">Please Select...</option>'); var str = prgyr.options[prgyr.selectedIndex].text + '|' + agy.options[agy.selectedIndex].value; $telerik.$.ajax({ type: "POST", url: pageUrl + '/LoadPortfolioDDL1', data: '{yearcode:"' + str + '"}', contentType: "application/json; charset=utf-8", dataType: "json", success: OnPortfolioData, failure: function (response) { alert(response.d); } }); } function OnPortfolioData(response) { PopulateControl(response.d, $telerik.$('#<%=ddlPortfolio.ClientID %>')); } function PopulateControl(list, control) { if (list.length > 0) { control.attr("disabled", false); control.empty(); $telerik.$.each(list, function () { control.append($telerik.$("<option></option>").val(this['Value']).html(this['Text'])); }); } else { control.empty().append('<option selected="selected" value="http://stackoverflow.com/questions/13879312/0">Not available<option>'); } }\[/code\]This works great when ddlAgency is first selected. If I make a second selection the displayed list is not updated and the original list is still displayed. However, if I select one of the items in the second list, the updated item (from the second call) is shown correctly. Is this a problem with IE? A little more info: the DDL I want to update is not populated with any data upon page load. If I select the DDL, it will not show any options. Even after I make a selection in the controlling DDL the second shows no items. If I do not click on the DDL, the items show up. It's like the DDL will keep what it had the first time it is clicked on. Does this make sense? What the heck is causing this? I know the data is being cleared and new options added but the page still shows the old list or none at all.
 
Back
Top