主机百科
测评与优惠

一个form表单中两个(或多个)提交按钮,分别提交到不同页面或者不同方法的实现方法

1
  &lt;!DOCTYPE html&gt;  &lt;html lang=&quot;en&quot;&gt;  &lt;head&gt;  &nbsp;&nbsp;&nbsp; &lt;meta charset=&quot;UTF8&quot;&gt;  &nbsp;&nbsp;&nbsp; &lt;title&gt;一个form表单,两个提交按钮&lt;/title&gt;  &lt;/head&gt;  &lt;body&gt;  &lt;form action=&quot;&quot; name=&quot;pay&quot; method=&quot;post&quot;&gt;  &nbsp;&nbsp;&nbsp; 姓名:&lt;input type=&quot;text&quot; name=&quot;name&quot;/&gt;&lt;br/&gt;  &nbsp;&nbsp;&nbsp; 单价:&lt;input type=&quot;text&quot; name=&quot;price&quot;/&gt;&lt;br/&gt;  &nbsp;&nbsp;&nbsp; 数量:&lt;input type=&quot;text&quot; name=&quot;num&quot;/&gt;&lt;br/&gt;  &nbsp;&nbsp;&nbsp; 总金额:&lt;input type=&quot;text&quot; name=&quot;total_fee&quot;/&gt;&lt;br/&gt;  &nbsp;&nbsp;&nbsp; &lt;button onclick=&quot;send(1)&quot;/&gt;在线支付&lt;/button&gt;  &nbsp;&nbsp;&nbsp; &lt;button onclick=&quot;send(2)&quot;/&gt;货到付款&lt;/button&gt;  &lt;/form&gt;  &lt;/body&gt;  &lt;/html&gt;  &lt;script&gt;  function send(type) {      var url = &#39;';      if(type === 1){          url = 'zaixianzhifu';      }else{          url = 'huodaofukuan';      }      document.pay.action = url;      document.pay.submit();  }  </script>

赞(0)
未经允许不得转载:主机阁 » 一个form表单中两个(或多个)提交按钮,分别提交到不同页面或者不同方法的实现方法

登录

找回密码

注册