jquery 怎样获取select多选下拉框所有选项的值
<form method="post" name="myform">
<table>
<tbody>
<tr>
<td>
部门:
@Html.DropDownList("groups", Html.GetDepartmentSelectList(), "请选择...", new Dictionary<string, object>
{
{"onchange", "createFunction();"}
})
<br />
<select id="leftItem" name="leftItem" multiple="multiple" size="20" style="height: 250px;
width: 250px;" ondblclick="moveOption(document.myform.leftItem, document.myform.rightItem)">
</select>
</td>
<td>
<input type="button" id="btnAdd" value="<< " onclick="moveOption(document.myform.rightItem, document.myform.leftItem)" /><br />
<input type="button" id="btnDel" value=" >>" onclick="moveOption(document.myform.leftItem, document.myform.rightItem)" /><br />
<input type="button" id="btnGroup" value="分配人员" onclick="save()" />
</td>
<td>
员工:<br />
<select id="rightItem" name="rightItem" multiple="multiple" size="20" style="height: 250px;
width: 250px;" ondblclick="moveOption(document.myform.rightItem, document.myform.leftItem)">
@{var i = 0;
foreach (var item in Model)
{
i++;
<option value="@i">
@item.EmployeeName
</option>
}
}
</select>
</td>
</tr>
</tbody>
</table>
</form>
[解决办法]
var realvalues = [];
var textvalues = [];
$('#rightItem :selected').each(function(i, selected) {
realvalues[i] = $(selected).val();
textvalues[i] = $(selected).text();
});
[解决办法]
post过去
另外你要搞清楚,哪些代码是在服务器端先执行的,哪些是服务器执行完毕了才发送到客户端执行的