【问题标题】:how to multiple post form with single button and open all in new tab如何使用单个按钮发布多个表单并在新选项卡中打开所有表单
【发布时间】:2016-04-30 06:03:04
【问题描述】:

我有 3 个具有相同功能的 postform,但我发送的信息不同,

如何创建单个按钮来执行所有按钮(1,2,3)?并且使用单个按钮而不是打开每个按钮的新标签(1,2,3)。

<?php $url = "http://example.com"; ?>

<form id="postform" action="<?php echo "$url" ?>/action.php" method="post" name="postform" target="_blank" enctype="multipart/form-data">
    <table id="message">
        <tbody id="post-message">
            <div id="post-subject">
                <input type="text" name="subject" id="subject" value="subject 1"></input>
            </div>
            <div id="post-message">
                <textarea name="message" id="code-message">message 1 here</textarea>
            </div>
            <div id="post-buttons">
                <td id="post-buttons"><input type="submit" name="submit" value="button 1"></td>
            </div>
        </tbody>
    </table>
</form>
<form id="postform" action="<?php echo "$url" ?>/action.php" method="post" name="postform" target="_blank" enctype="multipart/form-data">
    <table id="message">
        <tbody id="post-message">
            <div id="post-subject">
                <input type="text" name="subject" id="subject" value="subject 2"></input>
            </div>
            <div id="post-message">
                <textarea name="message" id="code-message">message 2 here</textarea>
            </div>
            <div id="post-buttons">
                <td id="post-buttons"><input type="submit" name="submit" value="button 2"></td>
            </div>
        </tbody>
    </table>
</form>
<form id="postform" action="<?php echo "$url" ?>/action.php" method="post" name="postform" target="_blank" enctype="multipart/form-data">
    <table id="message">
        <tbody id="post-message">
            <div id="post-subject">
                <input type="text" name="subject" id="subject" value="subject 3"></input>
            </div>
            <div id="post-message">
                <textarea name="message" id="code-message">message 3 here</textarea>
            </div>
            <div id="post-buttons">
                <td id="post-buttons"><input type="submit" name="submit" value="button 3"></td>
            </div>
        </tbody>
    </table>
</form>

感谢您的帮助。

【问题讨论】:

  • “执行所有按钮”是什么意思?这个问题非常不清楚。你希望它“执行”什么?如果您想提交所有三个“表单”,只需将它们组合成一个表单......?除非你将它们组合成一个单一的形式,否则不使用 javascript 就没有实际的方法可以做到这一点,但即使这样也似乎不正确/不正确。
  • 我只想用 1 个点击按钮提交我的 3 条不同的消息,在我的表单中,我有 3 个按钮,所以我必须一一点击。先生,你能给我一个解决方案吗?谢谢回复
  • 当然。将其全部设为一个表单而不是 3 个单独的表单,并将三个 textarea 的名称更改为不同。
  • 所以我不能一键打开 3 个不同显示我的消息的新标签?如果我把它全部做成一个表格,那不就是一个标签吗?先生,你能帮我拿个样品吗?
  • 正如我之前所说,这是不可能的没有javascript

标签: javascript php html


【解决方案1】:

您可以使用if(isset()) {...} 语句。 例如:

表格 1

if(isset($_POST['button'])) {
    ...
}

表格 2

if(isset($_POST['button'])) {
    ...
}

表格 3 ...

表格 4........

【讨论】:

  • 这如何解决用一个按钮提交三个单独的表单的问题?
  • 哦,对不起,我没有特别明白这个问题!我会做一个编辑
  • 谢谢先生,你能给我一份样品吗?包括我的表格?
  • 我只需要确定,您想打开 3 个具有特定主题的主题页面,并且需要 1 个按钮来执行此操作??
  • 是的,先生,此结果将显示我来自响应操作页面的不同消息,
猜你喜欢
  • 2015-10-23
  • 2019-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-14
  • 2014-04-07
相关资源
最近更新 更多