In my application, I have created an ajax autocompelete extender text box.Once the user chooses the value, I want to insert that value in my dropdownlist. The code for that purpose is:
function GetCode(source, eventArgs) {
var hfield = $get('<%=this.HiddenID.ClientID%>');
hfield.value = eventArgs.get_value();
//hfield has the value selected in the autocomplete text box
var abc = document.getElementById('<% =DropDownList2.ClientID %>');
for (var i = 0; i < abc.length ; i++) {
alert(abc.options[i].value);
if (abc.options[i].value == hfield.value) {
abc.options[i].selected = true;
break;
}
}
}
The problem here is: My value is not showing in the dropdownlist. When I tried to debug the code, I realized that the value does come in the dropdownlist but when this code exits, the value disappears from the dropdownlist.
I have no idea why the values are disappearing! Please help! Thank you!