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

问题描述 投票:1回答:1

我在JSP中有一个Drop down。如何从JSP中的<html:options>标签中获取选定的值。

<html:select property="temp_Id"  >  
<html:options collection="listmap" property="key"/>  
</html:select>  
java javascript jsp struts jsp-tags
1个回答
0
投票

将您的代码更改为

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

在您的JavaScript中添加以下内容

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

这应该做。谢谢。

© www.soinside.com 2019 - 2024. All rights reserved.