This is a situation I have never encountered previously. I开发者_运维技巧 am doing a survey where i have the same multi-select drop down in the same form. Basically it is a survey about cars, how many cars, the drivers of each car.....and so on. Each car is a new div with a unique id. Each div is a new page in the survey and has the same questions on it. Im good with all the other questions but there is a question called activities where a user can select multiple items, multi-select or it could be checkboxes. Not sure what to use. I just need to be able to store multiples, multiple times. I hope I explained this well enough. If not I can answer any questions you may have.
Example
<form>
<div id="page_1">
<select id="activities_1" name="activities" type="multiple">
</select>
</div>
<div id="page_2">
<select id="activities_2" name="activities" type="multiple">
</select>
</div>
.......
</form>
Give each input an unique name
.
<select name="activities1" multiple>
</select>
<select name="activities2" multiple>
</select>
To obtain the multiple submitted values on the same name in the servlet, use request.getParameterValues()
instead of request.getParameter()
.
String[] activities1 = request.getParameterValues("activities1");
String[] activities2 = request.getParameterValues("activities2");
精彩评论