java - how to Pass the value of listbox from jsp to servlet? -


my javascript is

function takelistboxvalue()     {         document.frmpartnerlist.submit();         var selectarray = new array();            (i = 0; < 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;     } 

you don't need js this. html enough.

<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> 

and in servlet use httpservletrequest#getparametervalues() obtain selected values:

string[] listbox = request.getparametervalues("listbox"); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -