图像在表单中提交按钮 [英] Image Submit Button within a Form
问题描述
我有一个表单,其形式为提交按钮。当用户点击图像按钮时,图像按钮应扮演提交按钮的角色。
代码示例:
< form action =page.phpmethod =POST>
< input type =imagename =btn_opentextboxsrc =image.pngvalue =Submit/>
< / form>
处理提交:
if($ _ POST ['btn_opentextbox'])
$ p $令人惊讶的是,上面的代码用于在Firefox中完美地工作。但是,一旦我昨天更新了我的Firefox,它根本不起作用。我点击按钮,页面刷新并没有任何反应。该代码在IE中也不起作用。
{
//做某事
}
注意:它可以在Chrome中使用。
我想要它在Firefox,IE等工作。
有什么建议?
解决方案您可以添加一个隐藏字段
< input type =hiddenname =actionvalue =Submit Form >
在php中,您可以做到这一点
<$ ($ _ POST ['action'] ==Submit Form){
做某事
}
/ pre>
希望得到这个帮助。
I have a form that has Submit button in form of an Image. When user clicks the image button, the image button should play the role of submit button.
Code Sample:
<form action="page.php" method="POST"> <input type="image" name="btn_opentextbox" src="image.png" value="Submit" /> </form>
Handle Submission:
if($_POST['btn_opentextbox']) { //do something }
Surprisingly, the above code used to work perfectly fine in Firefox. However, once i updated my Firefox yesterday, it didn't work at all. I click the button, page gets refreshed and nothing happens. The code also doesn't work in IE.
Note: it works in Chrome.
I want it to work in Firefox, IE, etc.
Any suggestions?
解决方案you can add a hidden field
<input type="hidden" name="action" value="Submit Form">
and in php you can do this
if($_POST['action'] == "Submit Form"){ do something }
hope this help.
这篇关于图像在表单中提交按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!