jsp:未发布ajax填充的dropbox的值
检索用ajax填充的dropbox的值时出现问题。无论选择什么值,相关参数和值都不存在。 我已经搜索了几天,但是没有找到这个问题的好答案,所以谢谢你的帮助。 以下是jsp站点的代码:jsp:未发布ajax填充的dropbox的值,ajax,jsp,servlets,Ajax,Jsp,Servlets,检索用ajax填充的dropbox的值时出现问题。无论选择什么值,相关参数和值都不存在。 我已经搜索了几天,但是没有找到这个问题的好答案,所以谢谢你的帮助。 以下是jsp站点的代码: <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <script lan
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<script language="javascript" type="text/javascript">
var xmlHttp
function showSockets(str){
if (typeof XMLHttpRequest != "undefined"){
xmlHttp= new XMLHttpRequest();
}
else if (window.ActiveXObject){
xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlHttp==null){
alert("Browser does not support XMLHTTP Request")
return;
}
var url="sockets_abstract.jsp";
url +="?room=" +str;
xmlHttp.onreadystatechange = socketChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
function socketChange(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
document.getElementById("socket").innerHTML=xmlHttp.responseText
}
}
</script>
<title>AJAX abstract</title>
</head>
<body>
<table align="center">
<thead>
<tr><td colspan="2" class="heading">Test ajax:</td></tr>
</thead>
<tbody>
<form action="show_parameters.jsp" method="post" name="mainForm">
<tr>
<td>Location*:</td>
<td>
<select name="location" size="1" onchange="showSockets(this.value)">
<option selected value="room1">room1</option>
<option value="room2">room2</option>
<option value="room3">room3</option>
</select>
</td>
</tr>
<tr>
<td>Socket*:</td><td>
<div id="socket">
<select name="room_socket" onchange="getSocket(this.value)">
<option value='-1'></option>
</select>
</div>
</td>
</tr>
<tr><td colspan="2"><hr width="80%"></hr></td></tr>
<input type="hidden" name="insert" value="true"/>
<tr><td colspan="2" align="right"><input style="width:100%" type="submit" value="Check Parameters" /></td></tr>
</form>
</tbody>
</table>
</body>
</html>
因此,套接字dropbox被完全忽略。
感谢您的帮助。表单标记不是
t正文
标记的有效子项。如果将表单标记移到表外,则效果良好
<form action="show_parameters.jsp" method="post" name="mainForm">
<table align="center">
<thead>
<tr><td colspan="2" class="heading">Test ajax:</td></tr>
</thead>
<tbody>
<tr>
<td>Location*:</td>
<td>
<select name="location" size="1" onchange="showSockets(this.value)">
<option selected value="room1">room1</option>
<option value="room2">room2</option>
<option value="room3">room3</option>
</select>
</td>
</tr>
<tr>
<td>Socket*:</td><td>
<div id="socket">
<select name="room_socket" onchange="getSocket(this.value)">
<option value='-1'></option>
</select>
</div>
</td>
</tr>
<tr><td colspan="2"><hr width="80%"></hr></td></tr>
<input type="hidden" name="insert" value="true"/>
<tr><td colspan="2" align="right"><input style="width:100%" type="submit" value="Check Parameters" /></td></tr>
</tbody>
</table>
</form>
测试ajax:
地点*:
1号房间
房间2
3号房间
插座*:
谢谢,很简单。
<%@page import="java.util.*" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP display all parameters</title>
</head>
<body>
<%
Enumeration en = request.getParameterNames();
while (en.hasMoreElements()) {
String parameterName = (String) en.nextElement();
String parameterValue = request.getParameter(parameterName);
out.println(parameterName+":"+parameterValue+"<br />");
}
%>
</body>
</html>
location:room3
insert:true
<form action="show_parameters.jsp" method="post" name="mainForm">
<table align="center">
<thead>
<tr><td colspan="2" class="heading">Test ajax:</td></tr>
</thead>
<tbody>
<tr>
<td>Location*:</td>
<td>
<select name="location" size="1" onchange="showSockets(this.value)">
<option selected value="room1">room1</option>
<option value="room2">room2</option>
<option value="room3">room3</option>
</select>
</td>
</tr>
<tr>
<td>Socket*:</td><td>
<div id="socket">
<select name="room_socket" onchange="getSocket(this.value)">
<option value='-1'></option>
</select>
</div>
</td>
</tr>
<tr><td colspan="2"><hr width="80%"></hr></td></tr>
<input type="hidden" name="insert" value="true"/>
<tr><td colspan="2" align="right"><input style="width:100%" type="submit" value="Check Parameters" /></td></tr>
</tbody>
</table>
</form>