如何使用单个按钮多个帖子表单并在新选项卡中打开所有

时间:2016-01-23 18:16:29

标签: javascript php html

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

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

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

表格1

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

表格2

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

表格3     ...

表格4 ........