我的javascript是
function takeListBoxValue()
{
document.frmPartnerList.submit();
var selectArray = new Array();
for (i = 0; i < partnerList.length; i++)
{
selectArray[i] = new Array();
selectArray[i][0] = partnerList.options[i].text;
selectArray[i][1] = partnerList.options[i].value;
}
document.frmPartnerList.<%=RateCardConstant.ACTION_MODE_PARAMETER%>.value='<%=(new Long(RateCardActionConstant.PARTNER_DOMAIN_LIST_ACTION).toString())%>&dataValue='+selectArray;
}
答案 0 :(得分:1)
你不需要JS。只需HTML即可。
<form action="servleturl" method="post">
<select name="listbox" multiple="true">
<option value="value1">label1</option>
<option value="value2">label2</option>
<option value="value3">label3</option>
</select>
<input type="submit">
</form>
然后在servlet中使用HttpServletRequest#getParameterValues()
来获取所选值:
String[] listbox = request.getParameterValues("listbox");