繁体   English   中英

两个提交按钮的表单相同

[英]two submit buttons for the same form

让我们说我有表格,最后我有两个按钮

1-发送测试表格

2-发送现场表格

两者都发送相同的表格。 如何将参数发送到服务器,以便知道它的测试状态还是实时状态?

谢谢

<form method='post' action='index.php?page=mailing&amp;campID=<?PHP echo $_GET['campID'] ?>&amp;act=<?PHP echo $actType ?>' id="Form" >     
    <table class="sort">
        <tr>
            <td>email address</td>
            <td><input type="text" name="emailTest" value="<?PHP echo $user_details['email'] ?>" /></td>
        </tr>
        <tr>
            <td></td>
            <td><a href="#" class="button3d" onClick="document.getElementById('Form').submit()">send test</a></td>
            <td><a href="#" class="button3d" onClick="document.getElementById('Form').submit()">send live</a></td>
        </tr>
    </table>
</form>

只需在php中检查“提交”字段是“测试”还是“实时”。

<form method='post' action='' id="Form" >     
    <table class="sort">
        <tr>
            <td>email address</td>
            <td><input type="text" name="emailTest" value="" /></td>
        </tr>
        <tr>
            <td></td>
            <td><button type="submit" name="submit" value="test">Test</button></td>
            <td><button type="submit" name="submit" value="live">Live</button></td>
        </tr>
    </table>
</form>

您将需要使用JS,一个提交按钮和一个单选按钮。 后者是更好的选择,因为您不会意外地将某些内容提交到错误的队列中。 另外,您实际上应该使用的是提交按钮,而不是锚点。

我希望使用单选按钮的原因是,一旦单击提交,您将无法返回。 单选按钮使您可以单击错误的按钮,然后进行更改。

 input[type="submit"] { background: none; border: 0; color: blue; text-decoration: underline; cursor: pointer; } 
 <form method='post' action='' id="Form"> <table class="sort"> <tr> <td>email address</td> <td> <input type="text" name="emailTest" value="" /> </td> </tr> <tr> <td> <input type="radio" name="testLive" value="test" id="test" /> <label for="test">Submit as Test</label> </td> <td> <input type="radio" name="testLive" value="live" id="live" /> <label for="live">Submit as Live</label> </td> </tr> <tr> <td colspan="2"> <input type="submit" value="Submit" /> </td> </tr> </table> </form> 

暂无
暂无

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

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