javascript如何获取html:form里面的下拉框的值
javascript怎么获取html:form里面的下拉框的值?
想在struts中做一个二级联动的下拉菜单
相关的ajax代码:
var url = "getChilds.jsp?id=?/这里不知怎么获取directoryId的值?顺便问一下,这样写联动可不可行?我是从另一个项目中移植过来的,它没有用strtuts标签,现在移到还有struts标签就不知怎么写了,请高手赐教,谢谢!!
------解决思路----------------------
var url = "getChilds.jsp?id=" + escape(document.getElementById('directoryId').value);
想在struts中做一个二级联动的下拉菜单
<html:form action="baseData/med.do" method="post" focus="title" enctype="multipart/form-data" onsubmit="return
save();">
<input type="hidden" name="command" value="add" />
<html:hidden property="id"/>
<tr>
<td align="right">类别:</td>
<td align="left">
<select id="directoryId" name="directoryId" onchange="change()">
<option value="0" selected="selected">
请选择主目录
</option>
<logic:iterate id="blist" name="dcs" scope="request">
<option value="${blist.id}">
${blist.name}
</option>
</logic:iterate>
</select>
<logic:present name="cs" scope="request">
<select name="categoryId" id="categoryId">
<logic:notEmpty name="cs" scope="request">
<logic:iterate id="ele" name="cs" scope="request">
<logic:equal value="${ele.id}" name="InfoForm" property="categoryId" >
<option value="<bean:write name='ele' property='id' />" selected>
<bean:write name="ele" property="name"/>
</option>
</logic:equal>
</logic:iterate>
</logic:notEmpty>
<tr>
<td colspan="2" align="center"><html:submit><bean:message key="button.submit" /></html:submit></td>
</tr>
</table>
</html:form>
相关的ajax代码:
<script type="text/javascript">
var req;
function init() {
if(window.XMLHttpRequest) {
req = new XMLHttpRequest();
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}
}
function change() {
init();
var url = "getChilds.jsp?id=" + escape(document.directoryId.options
[document.directoryId.selectedIndex].value);//这里不知怎么写?
req.open("GET", url, true);
req.onreadystatechange = callback;
req.send(null);
}
</script>
var url = "getChilds.jsp?id=?/这里不知怎么获取directoryId的值?顺便问一下,这样写联动可不可行?我是从另一个项目中移植过来的,它没有用strtuts标签,现在移到还有struts标签就不知怎么写了,请高手赐教,谢谢!!
------解决思路----------------------
var url = "getChilds.jsp?id=" + escape(document.getElementById('directoryId').value);