想要使此提交按钮触发2个不同的操作。
搜索 - 使用index.php操作,如图所示。
使用着陆页(或任何页面)打开新标签页或新窗口。
重要的是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>
答案 0 :(得分:0)
你不能在表单中放两个动作,但你可以做的是将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");
}