如何使.php表单提交按钮两个动作

时间:2014-07-13 09:26:04

标签: php forms button tabs submit

您好我想创建一个表单,将数据提交到XXXXXXX并在mydomain.com旁边打开一个新标签 请帮帮我......

<form action="XXXXXXXXXX" method="get" style="margin-top: 12px;">
        <label>
            <input type="text" name="user" value="" style="width: 100%" placeholder="Your Code Here" autocomplete="off" autofocus="" required>
        </label>
        <input type="submit" style="width: 84px;margin-top: 10px;" value="Submit" class="submit">
    </form>

请发给我一些详细信息要做这个..我首先在official-liker.net上提交这个按钮..

5 个答案:

答案 0 :(得分:2)

试试这个

<form action="XXXXXXXXXX" method="get" style="margin-top: 12px;" target=_blank>
    <label>
        <input type="text" name="user" value="" style="width: 100%" placeholder="Your Code
 Here" autocomplete="off" autofocus="" required>
    </label>

    <input type="submit" style="width: 84px;margin-top: 10px;" value="Submit"

   class="submit">
    </form>

target属性指定一个名称或关键字,指示在提交表单后显示收到的响应的位置。

答案 1 :(得分:0)

尝试以下内容

<form action="XXXXXXXXXX.php" method="get" target="_blank" style="margin-top: 12px;">

答案 2 :(得分:0)

为此,您需要使用jQuery使用AJAX提交表单,并通过

进行success回调
  

window.open(URL, '_空白');

答案 3 :(得分:0)

无需使用Javascript,您只需在表单标记中添加target="_blank"属性即可。

  <form action="XXXXXXXXXX" method="get" style="margin-top: 12px;" target=_blank>
            <label>
                <input type="text" name="user" value="" style="width: 100%" placeholder="Your Code Here" autocomplete="off" autofocus="" required>
            </label>
            <input type="submit" style="width: 84px;margin-top: 10px;" value="Submit" class="submit">
        </form>

以下链接有助于:HTML form target

答案 4 :(得分:0)

如果你想在Post标题(“Location:http://www.example.com/”)php函数之后获得重定向。 如果你想和你一起打开,可以使用JQuery。

<form>

   <input name="text2" type="text" id="text" />

<a class="className" href="#" name="save" id="saveButton">Save</A>

</form>

之后有一些JavaScript的东西:

$(document).ready(function() {
    $("#save").click(function(e) {
        e.preventDefault();
        $.post("sendPhp.php", { textPost : $("#text").val()},
              function(html) {
                   //open a new window here
                   window.open("mydomain.com");
              }
    });
});
相关问题