js控制select的options的几个选中和自动添加options值

判断第几个选中
if ('${da1}' == 1) {
document.forms[0].selZqda.options[1].selected = true;
}
if ('${da2}' == 2) {
document.forms[0].selZqda.options[2].selected = true;
}
自动添加值
function ajaxArea(){
id=document.getElementById("jhd0").value;
if(id ==""){
document.getElementById("deliverArea").options.length = 0;
document.getElementById("deliverArea").options.add(new Option("请选择",""));
}else{
document.getElementById("deliverArea").options.length = 0;
buffalo.remoteCall("springMarketConditionAjax.getArea",[id,],function(reply){
ret = reply.getResult();
for(var a=0;adocument.getElementById("deliverArea").options.add(new Option(ret[a].areaName,ret[a].areaName));
}
});
}
}
Tags: 

延伸阅读

最新评论

发表评论