当前位置:编程学习 > JS >>

表单提交后按钮变成灰色

我们在有些网站提交数据的时候会看到,当点击提交后,提交按钮变灰色不可用,这样可有效防止重复提交,本代码就是实现这样一个功能。从代码就可以看出,我们只需在提交按钮上加入这一句: onclick="javascript:{this.disabled=true;document.form1.submit();}",意思是当按钮点击后,将按钮的不可用属性设置为true,这样按钮就变灰了。
答案:<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"> 
<title>表单提交后按钮变成灰色</title> 
</head> 
<body> 
<form name=form1 method="POST" action="/" target=_blank><p><input type="text" name="T1" size="20"><input type="button" value="提交" onclick="javascript:{this.disabled=true;document.form1.submit();}"> 
<input type="reset" value="重置" name="B2"></p> 
</form> 
</body> 
</html>

上一个:点击文本框激活链接转向某网址
下一个:JavaScript 动态删除列表框的值

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,