日期:2014-05-17 浏览次数:20659 次
//根据值选中下拉菜单某项
function setSelectedValue(id,value){
var selectObj = document.getElementById(id);
for(i=0;i<selectObj.length;i++){
if(selectObj.options[i].value==value){
selectObj.options[i].selected = "selected";
}
}
}
//获取下拉菜单当前选择的值
function getSelectedValue(id){
var value = document.getElementById(id).value;
return value;
}
//根据值选择多个下拉选项
function setSelectedValues(id,values){
var selectObj = document.getElementById(id);
for(var i=0;i<values.length;i++){
value = values.split(",");
for(var j = 0;j<value.length;j++){
for(var k = 0;k<selectObj.length;k++){
if(selectObj.options[k].value==value[j]){
selectObj.options[k].selected = "selected";
}
}
}
}
}
//获取下拉菜单当前选中的多个值
function getSelectedValues(id){
var selectObj = document.getElementById(id);
var values = "";
for(var i = 0;i<selectObj.length;i++){
if(selectObj.options[i].selected){
var value1 = selectObj.options[i].value;
var value = value1 + ",";
va