0
我有一个组合框,它具有一些值,我也有一些值,我从组合框中选择一个值并进行一些操作并返回选定的值(在会话中设置这些值)。现在我需要自动选择组合框中会话的值。从动态创建的组合框中删除重复的值
我按照下面的JavaScript和它工作正常,但它创建了一个重复的值,它是已在组合框中:
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 = "";
}
谁能帮我鉴别?
这个链接可以帮助你:http://stackoverflow.com/questions/4590311/set-option-selected-attribute-from-dynamic-created-option – Anoop