[英]How to get id of selected option with jsp?
I have something like this in HTML: 我在HTML中有这样的东西:
<select name="selection">
<option id="1">First Option</option>
...
</select>
I would like to get the ID of the selected option in JSP. 我想在JSP中获取所选选项的ID。 request.getParameter("selection") gives me the text of the option but I want the id. request.getParameter(“selection”)给了我选项的文本,但我想要id。
Keeping id
and value
same will work for you. 保持id
和value
相同对你有用。
eg 例如
<option id="1" value="1">First Option</option>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.