【问题标题】:Calling 2 (two) actions with a submit form使用提交表单调用 2(两个)操作
【发布时间】:2018-02-24 18:36:10
【问题描述】:

想让这个提交按钮触发 2 个不同的动作。

  1. 搜索 - 使用 index.php 操作,如图所示。

  2. 打开一个新选项卡或带有登录页面(或任何页面)的新窗口。

重要的是 index.php 对我来说有一个“复杂”的编码,去那里会更加挑战自己。所以我更喜欢保留第一个函数,并以某种方式添加第二个“在这里”。 如何添加第二个动作?

<form class="destinations-form" action="index.php" method="post">
  <div class="input-line">
    <input name="search" type="text" name="destination" value="" 
     class="form-input check-value" placeholder="Looking for..." />
    <button type="submit" name="destination-submit" 
     class="form-submit btn btn-special">GO</button>
  </div>
</form>

【问题讨论】:

  • 不在你的问题中发布代码不会在这里赢得你的朋友......

标签: javascript php html forms submit


【解决方案1】:

您不能在表单中添加两个操作,但您可以将 index.php 更改为 index.php?p=landingPage

<form class="destinations-form" action="index.php?p=landingPage" method="post">
  <div class="input-line">
    <input name="search" type="text" name="destination" value="" 
     class="form-input check-value" placeholder="Looking for..." />
    <button type="submit" name="destination-submit" 
     class="form-submit btn btn-special">GO</button>
  </div>
</form>

然后在您的 index.php 中添加以下内容,它将重定向到您的登录页面。

if (isset($_GET['landingPage'])) {
    $redirect="http://mylandingpage.com";
    header("Location: $redirect");
}

【讨论】:

  • 试过了,但是没用。可能 index.php 中的某些内容会影响您的解决方案。
猜你喜欢
  • 2017-09-22
  • 2016-10-30
  • 1970-01-01
  • 1970-01-01
  • 2014-03-15
  • 2018-03-09
  • 1970-01-01
  • 2015-01-26
  • 1970-01-01
相关资源
最近更新 更多