使用链接提交表单时,保持按钮提交值 [英] Maintain button submit value when using link to submit a form
本文介绍了使用链接提交表单时,保持按钮提交值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试创建提交表单的链接。我使用它并且工作正常:
i am trying to create a link that submits a form. I use this and works fine :
<a name="submit" href="javascript:document.theForm.submit();" class="rollover-button gray small"><span>Send Message</span></a>
然而,我有一个问题。我以前的提交按钮是:
However, i have a problem. My previous submit button was :
<input type="submit" name="submit" value="Send Message" />
点击时,我得到了一个$ _POST ['submit']值,我正在检查与isset在我的PHP脚本,看看表单是否提交。但是,这不适用于我的提交链接。有人知道我该怎么做吗?
When this was clicked, i was getting a $_POST['submit'] value that i was checking with isset in my php script, to see whether the form is submitted or not. However, this does not work with my submit link. Does anybody know how i can do that ?
编辑:
我试过了, p>
I tried that, as suggested :
<form action="." name="theForm" class="contactForm" method="post">
<input type="hidden" name="submit" value="Send Message" />
</form>
<a name="submit" href="javascript:document.theForm.submit();" class="rollover-button gray small"><span>Send Message</span></a>
但仍然无效。
But still does not work.
推荐答案
您可以创建隐藏的输入类型并检查其是否存在:
You can create input type of hidden and check for its existence:
if (isset($_POST['hiddenName'])) {....}
这篇关于使用链接提交表单时,保持按钮提交值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文