form id="sa" name="sa" method="post" action="sa.php">
<fieldset>
<table id="show_post" class="tablesorter" border="0.5">
<tr>
<td>部门</td>
<td>
<select name="department[]" id="department[]" multiple="multiple" size = "4">
<option value="abc">abc</option>
<option value="da">da</option>
<option value="aaa">aaa</option>
<option value="ccc">ccc</option>
</select>
</td>
</tr>
<tr>
<td><input type="button" value="预览" onclick="show_confirm()" ></input></td>
<td><input type="submit" value="提交" class="button" ></input></td>
</tr>
</table>
</fieldset>
</form>
function show_confirm()
{
o = document.getElementByld("department[]");
var intvalue="";
for(i=0;i<o.length;i++)
{
if(o.options[i].selected)
{
intvalue+=o.options[i].value+",";
}
}
alert("部门: "+intvalue+"\n");}为何选定了几项 什么都没显示呢???
{
var arr=[];
var p = document.getElementById("department[]").options;
for(var i=0;i< p.length;i++){
if(p[i].selected){arr.push(p[i].value);}
}
alert("部门:"+ arr.join(','));
}