提交按钮变灰 [英] submit button grayed out
本文介绍了提交按钮变灰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在一个非常重要的表单上有一个提交按钮.我不希望用户多次单击它.有没有一种方法可以使它们在单击后不可点击或变灰. (也许是点击事件?).我的简单代码如下
I have a submit button on a form that is quite important. I do not want users clicking it more than once. Is there a way to make it unclickable or grayed out after they click it. (maybe an on click event?). My simple code is below
<form method='POST' action='index.php'>
<input type='text' name='text' id='text'>
<input type ='submit' value='submit' name='submit'>
</form>
推荐答案
您可以使用onclick事件来获取按钮并将其Disabled属性设置为true.
You can use an onclick event to grab the button and set its disabled property to true.
<input type ='submit' value='submit'
id="my_submit_button" name='submit'
onclick="document.getElementById('my_submit_button').disabled = 'disabled'">
disabled属性的语法非常愚蠢,为什么我不知道它不是布尔值,而是它的含义:
The syntax of the disabled attribute is pretty stupid, why it's not boolean I don't know but it is what it is:
http://www.w3schools.com/tags/att_input_disabled.asp
这篇关于提交按钮变灰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文