这是我在jsp中编写的代码
<form name="form" method="post" action="example" >
<select id="sel" name="sel" onclick="sel()">
<% DirectoryReader dir=new DirectoryReader();
String[] directories=dir.dropDown();%>
<option value=default>Please Select</option>
<%for(String direct:directories)
{%>
<option value=<%=direct %>><%=direct%></option>
<%} %>
</select>
</form>
</li>
</ul>
<ul class="filterui">
<li><label class="filter">Managed Server</label></li>
<li>
<select >
<option>Please Select</option>
<option></option>
</select>
</li>
</ul>
这是我写的脚本:
<script>
function sel(){
var sel = document.getElementById("sel");
var selectedValue = sel.options[sel.selectedIndex].text;
document.write(sel);
document.write(selectedValue);
}
</script>