在按钮一的情况下,html将表单发布到a.php,在按钮二的情况下将表单发布给b.php


html post form to a.php in case of button one, post form to b.php case of button two

我有一个问题,我不知道该在哪里搜索,也不知道这个问题以前是否被问过,所以如果是这样的话,请说出来。

我有一个html表单,它被提交到一个php文件中。

<form name="input" action="formaction.php" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form>

是否可以有两个提交按钮,一个按钮将表单发布到formaction.php,另一个按钮则将表单发布至anotheraction.php

<form name="input" action="html_form_action.asp" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit to formaction">
<input type="submit2" value="Submit to anotheraction">
</form>

找到解决方案

来源:http://www.plus2net.com/html_tutorial/submit-two.php

 <form name=f1 method=post action=test5.php> 
 <input type='submit' value='Open default action file test5.php' onclick="this.form.target='_blank';return true;"> 
 <input type='submit' value='Open test6.html' onclick="f1.action='test6.php'; return true;"> </form>

我不知道通常的方法是什么,但首先想到的是在单击按钮时使用javascript设置操作值。

HTML

<form name="input" id=input action="html_form_action.asp" method="get">
<input type="submit" value="Submit to formaction" onclick="document.getElementById('input').setAttribute('action', 'theaction.php');">

也许有更好的方法来实现这个想法。