怎样获取select里面的value?
设置隐藏域
代码如下:
<tr>
<td class="name">
选择类别 <select id="catalog" onChange="onChangeSelect();">
<option selected="selected" value="0">请选择</option>
<!--从监听器中取出数据-->
<c:forEach items="${applicationScope.header}" var="h">
<option value="${h.id}">${h.title}</option>
</c:forEach>
</select>
</td>
<td>
<!-- 通过隐藏域将pid(也就也就是header中的id, option中的value值)传到ViewHeaderServlet中 -->
<input type="hidden" id="pid" name="pid" value="?"/>
服务标题: <input type="text" name="newTitle"/>
</td>
</tr>
<script>
function onChangeSelect(){
document.getElementById("pid").value=document.getElementById("catalog").value;
}
</script>