var provinceObj = document.getElementById("province").options; for (var i=0; i<provinceObj.length; i++) { if (provinceObj[i].value == province) { provinceObj[i].selected = true; break; } } var pname = pro_select.value; city_select.innerHTML = "<option>--选择市--</option>"; //遍历城市列表 for (var j in city) { if (pname == city[j].pname) { var opt = document.createElement("option"); opt.innerText = city[j].cname; opt.setAttribute("value", city[j].cname); city_select.appendChild(opt); } } var city1 = '${data.city!}'; //Struts2中从实体中取值 var cityObj = document.getElementById("city").options; for (var i=0; i<cityObj.length; i++) { if (cityObj[i].value == city1) { cityObj[i].selected = true; break; } }