submitting a multiple values and hidden values on checkbox in html
Is there a way to submit multiple form fields by tying it to one checkbox eg:
<input type=hidden name=code value="cycle_code" />
<input type=checkbox name=vehicle value="cycle" />
<input type=hidden name=code value="car_code" />
<input type=checkbox name=vehicle value="car" />
I want to be able to check car and get car_code sub开发者_开发百科mitted also. and same for cycle
You could use javascript to dynamically set the value of the hidden field.
The HttpServletRequest
maps parameters like so: Map<String,String[]>
HTML form fields values are stored as a String
array. If there's only one value, it is just an array of one String
. In your case, you should have an array that looks something like this:
String[] param = request.getParameter("code");
param[0] => "cycle_code"
param[1] => "car_code"
精彩评论