简体   繁体   English

两个提交按钮的表单相同

[英]two submit buttons for the same form

Lets says that I have form and in the end I have 2 buttons 让我们说我有表格,最后我有两个按钮

1 - send test form 1-发送测试表格

2 - send live form 2-发送现场表格

both send the same form. 两者都发送相同的表格。 How can I send parameter to the server so I will know if its test or live? 如何将参数发送到服务器,以便知道它的测试状态还是实时状态?

Thanks 谢谢

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

Just check in php if 'submit' field is 'test' or 'live'. 只需在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>

You'll either need to use JS, or one submit button, and a radio button. 您将需要使用JS,一个提交按钮和一个单选按钮。 The latter is a better option, as you can't accidentally submit something to the wrong queue. 后者是更好的选择,因为您不会意外地将某些内容提交到错误的队列中。 Also, you should really be using a submit button, not an anchor. 另外,您实际上应该使用的是提交按钮,而不是锚点。

The reason I would prefer the radio buttons is because once you click submit, you're past the point of no return. 我希望使用单选按钮的原因是,一旦单击提交,您将无法返回。 The radio button allows you to to click the wrong one, and then change it. 单选按钮使您可以单击错误的按钮,然后进行更改。

 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