I have a combo box, which has got some values, also I have some few values, I select one value from combo box and do some manipulation and come back with the value selected (set these values in session). Now I need to automatically select the value which are in session in the combo box.
I have followed the below JavaScript and it works fine but it creates a duplicate value which is already in the combo box:
function addCombo() {
var reportID = '<%=reportid%>';
var reportName = '<%=reportname%>';
var textb = document.getElementById("reportnames");
var option = document.createElement("option");
option.text = reportName;
option.value = reportID;
option.selected='selected';
try {
textb.add(option, null); //Standard
}catch(error) {
textb.add(option); // IE only
}
textb.value = "";
}
Could anyone help me to identify?
I have not removed the value rather i added the following code, it solved me the problem.