简体   繁体   English

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

[英]How To Make .php form submit button two actions

Hello i want to make one form That Submits data to XXXXXXX and opens a new tab alongside with mydomain.com Please Help Me To Get This.. 您好,我想制作一个将数据提交到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>

Please Send me Some Details To Do This.. i Firstly Saw This on official-liker.net submit button.. 请给我发送一些详细信息以执行此操作。i首先,在Official-liker.net提交按钮上看到此内容。

Try this 尝试这个

<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>

The target attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form. target属性指定名称或关键字,该名称或关键字指示在提交表单后在何处显示收到的响应。

试试下面的东西

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

For that you would need to use jQuery to submit the form using AJAX and in it's success callback via 为此,您将需要使用jQuery来使用AJAX提交表单,并通过AJAX success回调

window.open(url,'_blank'); window.open(url,'_ blank');

No need for Javascript, you just have to add a target="_blank" attribute in your form tag. 无需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>

Following link will help: HTML form target 以下链接将有所帮助: HTML表单目标

If you want to get Redirected after the Post header("Location: http://www.example.com/ ") php function. 如果要在Post标头(“ Location: http : //www.example.com/ ”)php函数之后获取重定向。 If you want to open alongside you can use JQuery. 如果要同时打开,可以使用JQuery。

<form>

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

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

</form>

After that some JavaScript stuff: 之后,一些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");
              }
    });
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM