php一个表单有两个提交按钮,分别对应不同的处理页面,应该怎么实现

<form action="?">
<input type="submit" name="return" value=“归还”/>
<input type="submit" name="return" value=“报损”/>
</form>
要怎样做才能点归还按钮跳转的归还页面,点报损按钮跳转到报损页面处理呢?初学者求带,谢谢了!

你要的效果 ,需要 html+js+php支持。


需要的文件如下:

    网站根目录/form.html

    网站根目录/guihuan.php

    网站根目录/baosun.php

----------------------------------------------

【form.html 代码】

<html>

  <body>

    <form id="myform" action="" method="">

      <input type="text" name="money" value=""/>

        ...

      <button onclick="func_guihuan();">归还</button>

      <button onclick="func_baosun();">报损</button>

    </form>

    <script>

         function func_guihuan(){

             var element = document.getElementById('myform');

             element.action = 'guihuan.php';

             element.submit();

         }

         function func_baosun(){

             var element = document.getElementById('myform');

             element.action = 'baosun.php';

             element.submit();

        }

     </script>

  </body>

</html>


【guihuan.php 代码】

<?php

    var_dump($_POST);die;

?>


【baosun.php 代码】

<?php

    var_dump($_POST);die;

?>



----------------

再打个广告

香港主机免备案,马上用,便宜到家~~298元/年 300M

http://rudon.net/host_detail.php?IDProduct=1301

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-01-25
//点击按钮之后的PHP处理文件(action的地址),里面加个判断
if($_POST['return']=='归还'){
    include ("guihuan.html");  
}elseif($_POST['return']=="报损"){
    include("baosun.html");
}

第2个回答  2014-01-25
<form action="test.php" name='theForm'>
<input type'hidden' name='act'>
<input type="submit" name="return" value=“归还” onclick="document.forms['theForm'].act.value='guihuan';"/>
<input type="submit" name="return" value=“报损” onclick="document.forms['theForm'].act.value='baosun';"/>
</form>
第3个回答  推荐于2018-04-28
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function guihuan()
{
document.form.action="page1.php";
}
function baosun()
{
document.form.action="page2.php";
}

</script>
</head>

<body>
<form name="form" method="post">
<input type="text" name="name" />
<input type="submit" value="归还" onclick="guihuan()" />
<input type="submit" value="报损" onclick="baosun()" />
</form>
</body>
</html>本回答被提问者和网友采纳