在一个JSP页面里有两个FORM,一个是看得见的,一个是隐藏的,内容都一样,就一个上传文件框,用户只需填一个FORM,另一个隐藏的要自动获得第一个FORM里的内容,并提交到不同的ACTION里.该如何做呢?谢谢指教...我是用JS这样弄的,但不行...
<script language=javascript>
<!--
function OnButton1()
{
document.Form1.action = "http://www.aaa.com/test/a.do"
document.Form1.submit();
var upfile=document.Form1.theFile;
document.Form2.theFile=var upfile;
document.Form2.action = "http://www.bbb.com/test/b.do"
document.Form2.submit();
return true;
}
-->
</script>
<script language=javascript>
<!--
function OnButton1()
{
document.Form1.action = "http://www.aaa.com/test/a.do"
document.Form1.submit();
var upfile=document.Form1.theFile;
document.Form2.theFile=var upfile;
document.Form2.action = "http://www.bbb.com/test/b.do"
document.Form2.submit();
return true;
}
-->
</script>
解决方案 »
- 询问如何调用返回的xml格式的数据
- 如何区分刷新操作和转其他页面操作?
- jsp checkbox问题
- 【求救】eclipse运行中报错org.eclipse.core.runtime.CoreException
- jsp通过url传递参数(包含#)的问题,急求解,多给分!!谢谢
- 专门给分的帖子,大家不用进了!
- 关于实现like功能,由于不用数据库,所以想用代码实现like功能,帮帮忙!
- 郁闷啊,高手快来看看啊--sqlserver中自己建的表不能访问,只有系统自带的可以访问
- 有没有"另存为"的对话框!
- 用AIXS调试webService遇到带子节点的XML
- 怎么读/var/lib/tomcat/work/catalina/-/org/apache/jsp下的.java文件
- Applet如何连续播放声音1.wav,2.wav
---------->
var upfile=document.Form1.theFile.value;
document.Form2.theFile=var upfile;
------->
document.Form2.theFile=upfile;可以的,你再试试,或者把其中一个form的target设置为_blank,看得比较清楚
或者用httpwatch跟踪下
</form><iframe style="display:none" name="fm1"></iframe><script language=javascript>
<!--
function OnButton1()
{
document.Form1.action = "http://www.aaa.com/test/a.do"
document.Form1.submit();
var upfile=document.Form1.theFile;
document.Form2.theFile=var upfile;
document.Form2.action = "http://www.bbb.com/test/b.do"
document.Form2.submit();
return true;
}
-->
</script>
function OnButton1()
{
var upfile=document.Form1.theFile;
document.Form2.theFile=var upfile; // document.Form2.theFile=upfile;
document.Form1.action = "http://www.aaa.com/test/a.do";//少逗号
document.Form2.action = "http://www.bbb.com/test/b.do";//少逗号
document.Form1.submit();
document.Form2.submit();
//return true;
}//顺序是否有关,自己测试下
document.Form2.theFile=var upfile; // document.Form2.theFile=upfile;
----〉
var upfile = document.Form1.theFile.value;
document.Form2.theFile.value=upfile
<!--
function OnButton1()
{
document.Form1.action = "http://www.aaa.com/test/a.do";
var upfile=document.Form1.theFile.value; alert (upfile); document.Form2.theFile.value=upfile; alert (document.Form2.theFile.value); document.Form2.action = "http://www.bbb.com/test/b.do";
document.Form1.submit();
document.Form2.submit();
return true;
}
-->
</script>第一个alert有值,第二个是空的...
只要struts-config.xml配一下不就可以了
不知道这样行不行?
新手,多多指教。
PS,咋给分哪,小弟第一天来,不懂规矩
第二个ATION时你只要去拿就可以了不用做的那么高难度
大家交流交流.分的事只是一个游戏规则.
另:在问题列表处的最右边,有一个"管理" 点,在里面输入密码,然后给分,确定.
另:分已给,不知道拿到没?
因为上传文件框实际上是一个控件,它必须是通过鼠标点击选择文件然后获得值,而不能直接通过Javascript给它赋值!
所以你的Form2怎么都不能上传成功的!