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

时间:2013-07-17 10:07:47

标签: java javascript jsp struts jsp-tags

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

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

1 个答案:

答案 0 :(得分:0)

将您的代码更改为

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

在java脚本中添加以下内容

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

这应该做。谢谢。