R
roohbir
Hello,
I have an HTML form which has an drop down box. I want to display the
selected option from this from a Servlet. I am having problems with
this and have a feeling I am not extracting data from the drop-down
box properly. I would be really thankful if somebody can point out
what the error is. The Servlet sends the response but only 0 is
displayed while the user's choice might have been 1 or 2 or 3 or 4.
The drop down box code in html is as follows:
<td>Socks</td>
<td>4</td>
<td><select name="socks" size="1">
<option selected="selected" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td>
</tr>
<tr>
<td>Shirt</td>
<td>16</td>
<td><select name="shirt" size="1">
<option selected="selected" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td>
</tr>
The Servlet code for extraction is here:
// extract data from the drop-down buttons here
int sockQuantity =
Integer.parseInt(request.getParameter("socks"));
int shirtQuantity =
Integer.parseInt(request.getParameter("shirt"));
int trouserQuantity =
Integer.parseInt(request.getParameter("trouser"));
int jumperQuantity =
Integer.parseInt(request.getParameter("jumper"));
int shoeQuantity =
Integer.parseInt(request.getParameter("shoes"));
Thanks in advance.
ros060
I have an HTML form which has an drop down box. I want to display the
selected option from this from a Servlet. I am having problems with
this and have a feeling I am not extracting data from the drop-down
box properly. I would be really thankful if somebody can point out
what the error is. The Servlet sends the response but only 0 is
displayed while the user's choice might have been 1 or 2 or 3 or 4.
The drop down box code in html is as follows:
<td>Socks</td>
<td>4</td>
<td><select name="socks" size="1">
<option selected="selected" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td>
</tr>
<tr>
<td>Shirt</td>
<td>16</td>
<td><select name="shirt" size="1">
<option selected="selected" value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td>
</tr>
The Servlet code for extraction is here:
// extract data from the drop-down buttons here
int sockQuantity =
Integer.parseInt(request.getParameter("socks"));
int shirtQuantity =
Integer.parseInt(request.getParameter("shirt"));
int trouserQuantity =
Integer.parseInt(request.getParameter("trouser"));
int jumperQuantity =
Integer.parseInt(request.getParameter("jumper"));
int shoeQuantity =
Integer.parseInt(request.getParameter("shoes"));
Thanks in advance.
ros060