javascript对select标记进行清除和添加
清除
for (var i = document.getElementById('Group').options.length - 1; i >= 0; i--) {
document.getElementById('Group').options.remove(i);
}
或者
document.getElementById("Group").innerHTML = "";
添加
for (var i = 0; i <= returnvalue.split('$').length - 1; i++) {
var oOption = document.createElement("OPTION");
document.getElementById('Group').options.add(oOption);
oOption.innerText = returnvalue.split('$')[i].split('|')[0];
oOption.value = returnvalue.split('$')[i].split('|')[1];
}
PS 得到所选项的值和文字
document.getElementById('Group').options[document.getElementById('Group').selectedIndex].value
document.getElementById('Group').options[document.getElementById('Group').selectedIndex].innerText