如何防止提交按钮被按两次
我试图阻止系统用户不在 Oracle ApEx 中按两次“提交”按钮,但不确定如何使用 jQuery 定位以下代码,即:
<a href="javascript:doSubmit('MY_SUBMIT')">
<img border="0" id="MS_BTN" alt="Submit Request" src="submit_btn.gif">
</a>
我基本上想确保所有必需的表单验证都已通过并且当用户按下“提交”按钮时,我想在按下按钮后立即隐藏该按钮。
我尝试了以下代码,因为我无法使用 src 值,即:
$("a:contains('MY_SUBMIT')").hide();
但这不起作用。
如何将此按钮添加到 onclick 事件中,并在成功的初始单击后基本上对用户隐藏此按钮?
I am trying to prevent the users of a system to not press the “Submit” button twice within Oracle ApEx but am unsure how to target the following code using jQuery, i.e.:
<a href="javascript:doSubmit('MY_SUBMIT')">
<img border="0" id="MS_BTN" alt="Submit Request" src="submit_btn.gif">
</a>
I basically want to make sure that all required form validation has passed and when the user presses the “Submit” button, I would like to somehow hide the button immediately after it has been pressed.
I have tried the following code as I cannot use the src value, i.e.:
$("a:contains('MY_SUBMIT')").hide();
But this did not work.
How can I add this button to an onclick event and basically hide this button from the user on the successful initial click?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
以下是如何使用 jQuery 执行此操作的示例:
HTML:
代码(加载文档后运行):
并且,一个工作示例: http://jsfiddle.net/jfriend00/CtpLU/
或者,您可以仅使用图像而不使用
标签,如下所示:
除了隐藏按钮是:
Here's an example how to do this with jQuery:
HTML:
Code (run after document has loaded):
And, a working example: http://jsfiddle.net/jfriend00/CtpLU/
Or, you could do it with only the image and no
<a>
tag like this:Other possible solutions besides hiding the button are:
也许设置一个全局变量,当第一次单击链接时该变量会发生变化
Maybe set a global var that changes when the link is first clicked
为锚标记提供一些 ID,然后您可以使用以下代码
希望这会有所帮助。
谢谢。
Provide some ID to the anchor tag and then you may use the following code
Hope this helps.
Thanks.
最好的办法是向
元素添加一个 ID,否则以某种方式定位图像父级:
理论上任何属性都可以作为目标,甚至是“alt”属性。
Best thing would be to add an ID to the
<a>
element, otherwise target the image parent somehow:Any attribute can in theory be targeted, even the "alt" attribute.