Borut Flis
Borut Flis

Reputation: 16405

How to get id of selected option with jsp?

I have something like this in HTML:

<select name="selection">
    <option id="1">First Option</option>
    ...
</select>

I would like to get the ID of the selected option in JSP. request.getParameter("selection") gives me the text of the option but I want the id.

Upvotes: 0

Views: 3501

Answers (1)

Hardik Mishra
Hardik Mishra

Reputation: 14887

Keeping id and value same will work for you.

e.g.

<option id="1" value="1">First Option</option>

Upvotes: 2

Related Questions