图像在表单中提交按钮 [英] Image Submit Button within a Form

查看:76
本文介绍了图像在表单中提交按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表单,其形式为提交按钮。当用户点击图像按钮时,图像按钮应扮演提交按钮的角色。



代码示例:

 < form action =page.phpmethod =POST> 
< input type =imagename =btn_opentextboxsrc =image.pngvalue =Submit/>
< / form>

处理提交:

  if($ _ POST ['btn_opentextbox'])
{
//做某事
}


注意:它可以在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆