我的html有一个选择选项值框,如果我从该框中选择任何选项,我将在javascript中获得值,但我想在jsp中使用此值,因为使用此字符串我显示从数据库中选择的行,我尝试请求.getparameter也没有用 代码:
<script type="text/javascript">
function getAppId()
{
var value=document.getElementById("planeselect").value;
document.getElementById("demo").innerHTML="application Id:"+value;
}
</script>
<select id="planeselect" onchange="getAppId()">
<%
Set<String> set=appsList.keySet();
for (String s:set) {
String appName = (String) appsList.get(s);
%>
<option value="<%=s%>"><%=appName%></option>
<%
}
%>
</select>
答案 0 :(得分:0)
在更改后,您可以加载页面并使用 request.getParameter()
<script type="text/javascript">
function getAppId()
{
var value=document.getElementById("planeselect").value;
document.getElementById("demo").innerHTML="application Id:"+value;
window.location="URL_of_this_page?RequiredValue="+value;
}
</script>
<%
String ValueRequired=request.getParameter("RequiredValue");
if(ValueRequired!=null){
*****operation which you want to perform*****
}
%>
<select id="planeselect" onchange="getAppId()">
<%
Set<String> set=appsList.keySet();
for (String s:set) {
String appName = (String) appsList.get(s);
%>
<option value="<%=s%>"><%=appName%></option>
<%
}
%>
</select>