javascript select小计

//DWR从后台拿值给select
DWRUtil.removeAllOptions("PP");DWREngine.setAsync(false);
// 加载页面时执行以下动作
           //DWRUtil.removeAllOptions("PP");
addOption("PI", "", "请选择");
addOption("PP", "", "请选择");
addOption("PR", "", "请选择");
addOption("PC", "", "请选择");
// 加载页面时获取PI内容
ICPPBIInfoService.getPIList(function(data) {
DWRUtil.addOptions("PI", data, "pbiId", "name");
});
         //$("PC").value = ""; Jquery应用
DWREngine.setAsync(true);

// 匹配并选中下拉框的某option
function selectOption(selectName, optionValue) {
var objSelect = document.getElementById(selectName);
var itemCount = objSelect.length;
for ( var i = 0; i < itemCount; i++) {
// 让Value=optionValue的那一项选中
if (objSelect[i].value == optionValue) {
objSelect.selectedIndex = i;
}
}
}
// 添加一个option
function addOption(selectName, value, text) {
var objSelect = document.getElementById(selectName);
var objOption = new Option(text, value);
var pos = objSelect.length + 1;
try {
objSelect.add(objOption, pos);
} catch (ex) {
objSelect.add(objOption, null);
}
}

你可能感兴趣的:(JavaScript,jquery,DWR)