检测PHP图像提交按钮点击
有一个带有提交按钮图像的 php 表单。我试图确定页面回发时是否单击了提交按钮。已尝试
$testForm = 'fail';
if (isset($_POST['btnSubmit'])) {
$testForm = 'Submit clicked';
}
按钮代码:
<input name="btnSubmit" value="Submit" style="float: right;" type="image" src="images/submit.gif" width="181" height="43" alt="Submit Form" />
但它似乎不起作用。已尝试获取页面上其他输入元素的值,它们工作正常。有没有一些特殊的方法来处理图像按钮?
Have a php form with an image for the submit button. Am trying to determine whether the submit button has been clicked when the page posts back. Have tried
$testForm = 'fail';
if (isset($_POST['btnSubmit'])) {
$testForm = 'Submit clicked';
}
button code:
<input name="btnSubmit" value="Submit" style="float: right;" type="image" src="images/submit.gif" width="181" height="43" alt="Submit Form" />
However it doesn't seem to be working. Have tried getting values of other input elements on the page and they work fine. Is there some special method for dealing with image buttons?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
图像按钮在提交时将单击的坐标作为
[name]_x
和[name]_y
提交,而不是将其值作为[name]
(有些浏览器也这样做,但不是全部,而坐标是从每个浏览器设置的)。也就是说,您可以简单地检查:a image-button submits the clicked coordinates as
[name]_x
and[name]_y
on submit instead of its value as[name]
(some browsers also do this, but not all, while the coordinates are set from every browser). that said, you could simply check: