多选下是添加multiple的option,按照一般做法只能取第一个,因此需要遍历一个selected.

 

jQuery下,返回一个字符串:



function getMsgDelStaValue() { var status=[];; $('#message_delivery_status option:selected').each(function(){ status.push($(this).val()) }) return status.join(","); }



 

js方式:



function getMsgDelStaValue() { var status=[]; var obj = document.getElementById("xxxx"); for(var i=0;i<obj.options.length;i++){ if(obj.options[i].selected){ status.push(obj.options[i].value); } } return status.join(","); }