由于特殊原因。需要再一个jsp页面页面里写两个form
每个form都action到不同的servlet进行处理,
问;大伙说说当我点击form a的"提交" 时,form b的bb内容会到达bservlet吗?
<body>
<form name="a" action="aservlet" method="post">
<input type="text" name="aa" >
<input type="submit" name="sub" value="提交">
</form>
<from name="b" action="bservlet" method="post">
<input type="text" name="bb" >
</form>
</body>
每个form都action到不同的servlet进行处理,
问;大伙说说当我点击form a的"提交" 时,form b的bb内容会到达bservlet吗?
<body>
<form name="a" action="aservlet" method="post">
<input type="text" name="aa" >
<input type="submit" name="sub" value="提交">
</form>
<from name="b" action="bservlet" method="post">
<input type="text" name="bb" >
</form>
</body>
解决方案 »
- 在java中JinternalFrame最小化后怎么样让它恢复原来的大小
- SWT中combo设置数据问题
- 我实在是搞不明白,请高手一定教教我!
- 下面是一个玩骰游戏!!!能通过,但是不能出现结果!!请高手来帮忙解答。
- 如何把数据库里面的字符取出来,连成表达式,算出来呢
- NetBeans安装问题(我已经找过旧贴了,还是找不到答案)
- 为什么不输出 this is a error
- 如何打开jpanel???????、、、在线等待!!!!
- 高手请进入讨论:关于覆盖重载隐藏:隐藏是动态绑定的吗?是多态性吗?
- 排列组合?
- 关于java数组默认值的问题
- 各位我编的一个JAVA文件在运行的时候出现"javaapplication2.NewClass@35ce36"请问如何解释?????
因为一点击“提交”页面就刷新了,如果在form b里面再加上一个"提交"按钮的话根本没有用啊
如果不会自己写个JS在A递交的时候也剪辑B的提交按钮
<js>
function get(){
document.getelementById("bb1").value=document.getelementById("bb").value
document.a.submit;
}
</js>
<body>
<form name="a" action="aservlet" method="post">
<input type="text" name="aa" >
<input type="text" name="bb" style="display:none" id="bb1">
<input type="button" name="sub" value="提交" onclick="get();">
</form>
<from name="b" action="bservlet" method="post">
<input type="text" name="bb" id="bb">
</form>
</body>
也可以将BB的值加到URL后传过去,不过处理中文起来就麻烦点了……
<%@ page contentType="text/html;charset=GBK" language="java"%>
<html>
<head>
<script type="text/javascript">
function sub()
var v=document.getElementById("b");
v.submit();
</script>
</head>
<body>
<form name="a" id="a" action="#" method="post">
<input type="text" name="aa" value="aa">
<input type="submit" name="suba" value="提交" onClick="sub">
</form>
<form name="b" id="b" action="#" method="post">
<input type="text" name="bb" value="bb">
</form>
<% String aa=request.getParameter("aa");
String bb=request.getParameter("bb");
out.println("aa="+aa+" "+"bb="+bb);
%>
</body>
</html>
特此申明
我上面写的jsp只是测试页面,所以提交到当前页面处理,看看效果怎么样啊,
我说的是我自己的代码作废,你太快了,插了一脚……2个form能同时提交么?2个请求你让服务器先响应哪个呢?直接这样处理不了吧,先处理a,再处理b~
报错:对象不支持此属性或方法
<body>
<form name="a" action="aservlet" method="post">
<input type="text" name="aa" >
<input type="submit" id="aa" style:"display:none">
</form>
<from name="b" action="bservlet" method="post">
<input type="text" id="bb" >
<input type="submit" name="bb" style:"display:none">
</form>
<input type="button" value="tijiao" onclick="submitaandb();"
</body>
<js>
function submitaandb(){
document.getElementById("aa").click();
document.getElementById("bb").click();
}
</js>
不知道这样行不行?
<%@ page import="javax.naming.*" contentType="text/html;charset=utf-8"%>
<%
DQ.UserDO userDO = (DQ.UserDO)session.getAttribute("loginUser");
DQ.FunctionDO[] functionDO = userDO.getFunction();
boolean isChked = false;
for(int i=0;i<functionDO.length;i++){
if( functionDO[i].getId()==10)
isChked = true;
}
if(!isChked) return ;
Object obj = session.getAttribute("UploadLogo");
if(obj !=null){
Exception e = (Exception) obj;
String errMsg = e.getMessage();
out.print("<script language='javascript'>alert('"+errMsg+"')</script>");
} session.setAttribute("UploadLogo", null);
%>
<style type="text/css">
<!--
.STYLE1 {
font-size: 12px;
font-style: italic;
}
-->
</style><DIV align="center">
<form action="UploadLogo?logoType=big" id='thisform' name='thisform' method='post' enctype="multipart/form-data">
<table cellpadding="0" cellspacing="0" cols="1" width="100%">
<tr>
<td colspan="1" valign="bottom" align="left" height="20"><strong>Upload logo in the login page </strong></td>
</tr>
<tr >
<td colspan="1">
<hr width="100%">
</td>
</tr>
<tr>
<td>
<table cellpadding="7" cellspacing="7" cols="2" width="100%">
<tr >
<td bgcolor="#eeeeee" width="100" colspan="1" align="right"><br /> </td>
<td bgcolor="#eeeeee" colspan="1" ><br />
<input type="file" id="filePath" name="filePath" size="70">
<br />
<span class="STYLE1">(File format: jpg. Suggested image size: 275x93 pixels.)
</span></td>
</tr>
<tr bgcolor="#eeeeee">
<td colspan="2" align="center">
<input style="CURSOR: hand" type="submit" id="upload" name="upload" value="Upload" >
<input style="CURSOR: hand" type="reset" id="clear" name="clear" value="Reset" > </td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</DIV>
<p> </p>
<form action="UploadLogo?logoType=small" id='thisform2' name='thisform2' method='post' enctype="multipart/form-data" >
<table cellpadding="0" cellspacing="0" cols="1" width="100%">
<tr>
<td colspan="1" valign="bottom" align="left" height="20"><strong>Upload logo in the page header </strong></td>
</tr>
<tr >
<td colspan="1"><hr width="100%" />
</td>
</tr>
<tr>
<td><table cellpadding="7" cellspacing="7" cols="2" width="100%">
<tr >
<td bgcolor="#eeeeee" width="100" colspan="1" align="right"><br />
</td>
<td bgcolor="#eeeeee" colspan="1" ><br />
<input type="file" id="filePath" name="filePath" size="70" />
<br />
<span class="STYLE1">(File format: gif. Suggested image size: 113x25 pixels.)
</span></td>
</tr>
<tr bgcolor="#eeeeee">
<td colspan="2" align="center"><input style="CURSOR: hand" type="submit" id="upload" name="upload" value="Upload"" />
<input style="CURSOR: hand" type="reset" id="clear2" name="clear2" value="Reset">
</td>
</tr>
</table></td>
</tr>
</table>
</form>
<p> </p>
最后面的那个input到底属于哪个form?点击他页面无任何反映啊
我说的楼上是你的楼上啊
<script type="text/javascript">
function submit(){
document.a.submit;
document.a.submit;
}
</script >
<body>
<form name="a" action="aservlet" method="post">
<input type="text" name="aa" >
<input type="button" name="sub" value="提交" onclick="submit();">
</form>
<from name="b" action="bservlet" method="post">
<input type="text" name="bb" id="bb">
</form>
</body>这样可以同时提交多个表单,并且后台servlet的处理顺序和表达的提交顺序是一样的,如果在servlet里有页面跳转的话,那么执行完后跳转的页面取决于最后执行的servlet
document.a.submit;-----------------
写错了,
document.a.submit;
document.b.submit;你在2个servlet里打印点东西看看,看程序是否运行到那里了
document.getElementByName("bb");
应该是getElementById
根据你的解法。我改了测试页面。代码如下.
因为一张jsp就是一个 servlet。现在,测试页面的action暂时提交到本页,说明这两个form是提交到同一个servlet.如果提交到两个不一样的servlet处理,那么提交到同一个servlet应该也没有问题吧?,可是,我就是测不通啊
<%@ page contentType="text/html;charset=GBK" language="java"%>
<html>
<head>
<script type="text/javascript">
function submit(){
document.a.submit;
document.b.submit;
}
</script>
</head>
<body>
<form name="a" action="#" method="post">
<input type="text" name="aa" >
<input type="button" name="sub" value="提交" onclick="submit();"></form>
<form name="b" action="#" method="post">
<input type="text" name="bb" id="bb">
</form>
</body>
<% String aa=request.getParameter("aa");
String bb=request.getParameter("bb");
out.println("aa="+aa+" "+"bb="+bb);
%>
</html>
function checka() {
var f = document.forms[0];
f.submit();
}
function checkb() {
var f = document.forms[1];
f.submit();
}
</script>
<body>
<form name="a" action="aservlet" method="post">
<input type="text" name="aa">
<input type="button" name="sub" value="提交a" onclick="checka()">
</form>
<form name="b" action="bservlet" method="post">
<input type="text" name="bb">
<input type="button" name="sub" value="提交b" onclick="checkb()">
</form> </body>
我只写了这个页面测试,这样是可以的.楼主再试试.