一个表单两个提交按钮提交不同页面

WBOY
Release: 2016-06-23 13:56:43
Original
951 people have browsed it

<form   method="get" name="myForm" action="test5.php" ><table >	<tr ><td>查询起始时间:<input type="datetime-local" name="start"/></td></tr>	<tr ><td>查询截止时间:<input type="datetime-local" name="end"/></td></tr>	<tr ><td><input type="submit" name="chaxun"  value="查询"  />  //查询按钮提交给test5.php 	<input type="button" name="down"  value="导出xls文件"  /> </td>       //导出xls文件按钮提交给down.php         </tr></table></form>初学,试了几种方法都不行,就只有action提交给哪个页面,哪个页面可以成功,求高手赐教
Copy after login



回复讨论(解决方案)

在按钮 down 的 onclick 事件中修改表单的 action 属性和执行表单的 submit 方法

<script language=javascript>    function down() {        document.all.myForm.action = "down.php";        document.all.myForm.submit();    }</script><form   method="get" name="myForm" action="test5.php" ><table>	<tr ><td>查询起始时间:<input type="datetime-local" name="start" size="20"/></td></tr>	<tr ><td>查询截止时间:<input type="datetime-local" name="end" size="20"/></td></tr>	<tr '><td><input type="submit" name="chaxun" value="查询"    /> //查询按钮提交给test5.php 	<input type="button" name="down" value="导出xls文件" onclick="down()" /> //导出xls文件按钮提交给down.php		</td>> 	</tr></table></form>
Copy after login


你说的是这个意思吗?我试了,"导出xls文件" 按钮还是没有响应

all 啊户型只有 ie 支持
说以应该是

<input type="button" name="down" value="导出xls文件" onclick="down(this.form)" />
Copy after login
function down(form) {   form.action = "down.php";   form.submit();}
Copy after login

我用的是谷歌浏览器,还是不行,只有第一个按钮起作用,心都碎了了

遇到类似的问题 。不用在一个同一个form标签写 。 在新建一个
//导出xls文件按钮提交给down.php


各种行不通后,用了种笨笨的办法,把form的action提交给第三个页面 3.php,接收下面两个的值

查询起始时间:<input type="datetime-local" name="start" size="20"/> 查询截止时间:<input type="datetime-local" name="end" size="20"/>
Copy after login


然后判断提交哪个按钮,再去响应相应的页面

谢谢斑竹

遇到类似的问题 。不用在一个同一个form标签写 。 在新建一个 
 

   
  
            //导出xls文件按钮提交给down.php         
  
 
 



这样的话怎么得到第一个form中前两个t的值,我要跳转的两个页面都需要这个值
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!