简体   繁体   English

如何从 html:options 集合中获取 Selected 选项值

[英]How to get Selected option value from html:options collections

I am having an Drop down in my JSP.我的 JSP 中有一个下拉菜单。 How to get selected value from <html:options> tag in JSP.如何从 JSP 中的<html:options>标记中获取选定的值。

<html:select property="temp_Id"  >  
<html:options collection="listmap" property="key"/>  
</html:select>  

Change your tag to将您的标签更改为

<html:select property="temp_Id" styleId = "tempId" >
html:options collection="listmap" property="key"/>  
</html:select>

Add the following in your java script在您的 java 脚本中添加以下内容

var e = document.getElementById("tempId");
var strUser = e.options[e.selectedIndex].value;  

This should do.Thanks.这应该可以。谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM