1 //多选回显 2 var countrylist = new Array(); 3 namelist = "${listCountry}".replace('[','').replace(']','').split(','); 4 function selectMul() { 5 var i = 0; 6 var j = 0; 7 for(j=0;j<namelist.length;j++) { 8 var sel = document.getElementById("arriveContry"); 9 for(i=1;i<sel.options.length;i++) { 10 if(sel.options[i].value==trim(namelist[j])) { 11 sel.options[i].selected="selected"; 12 } 13 } 14 } 15 } 16 //去掉字符串两遍的空格 17 function trim(str) 18 { 19 return str.replace(/(^\s*)|(\s*$)/g, ''); 20 }