问一个:一个form能否同时提交到2个action?
比如现在有个页面main.jsp
现在他左边嵌入了一个iframe,src main1.jsp
在main.jsp中有个form,有时候要提交数据到main1.jsp,根据条件查询数据库内容
同时,main.jsp自身也要发生变化(刷新内容)
有时候不需要刷新(不需要提交2次)
那位能告诉我能刷新提交2次吗?google.baidu.都差了,没有相关资料
我现在的做法是:先提交到main1.jsp,然后由main1.jsp去调用main.jsp中js方法去更新
(可以使用ajax去更新)
/****************/
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>main body</title>
</head>
<body>
<%
String sortType = request.getParameter("sortType") == null ? "" : request.getParameter("sortType").trim();
%>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<form action="main1.jsp" method="post" target="main1">
类型:<input type="text" id="sortType" name="sortType" value="<%=sortType%>"/>
<input type="submit">
</form>
</td>
<td>type: <%=sortType%></td>
</tr>
<tr>
<td><iframe name="main1" id="main1" src="main1.jsp"></iframe></td>
<td>bbb value:<span id="bbb"></span></td>
</tr>
</table>
</body>
</html>
<script type="text/javascript">
function $(s){
if (document.getElementById(s)){
return document.getElementById(s)
}else{
alert("i can not get object,its id:"+s);
return false;
}
}
function dosubmit(){
alert("dosubmit");
//document.forms[0].action="main1.jsp";
//alert("dosubmit:"+document.forms[0].action+"---sorttype:"+$(sortType).value);
document.forms[0].submit;
}
function setdata(sorttype){
alert("main.jsp----"+sorttype);
$("sortType").value=sorttype;
$("bbb").innerText=sorttype;
}
</script>
/****************/
/****************/
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>main1</title>
</head>
<%
String sortType = request.getParameter("sortType") == null ? "abc" : request.getParameter("sortType").trim();
System.out.println("sortType:"+sortType);
%>
<table width="60%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<form action="main1.jsp" method="post" >
类型:<input type="text" name="sortType" value="<%=sortType%>"/>
<input type="submit" name="submit" >
</form>
</td>
<td>type: <%=sortType%></td>
</tr>
<tr>
</tr>
</table>
</body>
</html>
<script type="text/javascript">
function $(s){
if (document.getElementById(s)){
return document.getElementById(s)
}else{
//alert("i can not get object,its id:"+s);
return false;
}
}
function setmaindata(sorttype){
alert("main1.jsp----"+sorttype);
top.setdata(sorttype);
}
</script>
<script>
setmaindata('<%=sortType%>');
</script>
/****************/
--
FROM 59.108.125.*