六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 61|回复: 0

按钮变灰

[复制链接]

升级  66.8%

262

主题

262

主题

262

主题

进士

Rank: 4

积分
834
 楼主| 发表于 2013-2-7 15:25:18 | 显示全部楼层 |阅读模式
<input class="button" type="submit" name="rulesubmit" value="同 意" style="height: 23px"><input class="button" type="button" name="return" value="不同意" style="height: 23px" ></center></form><script type="text/javascript">var secs = 9;var wait = secs * 1000;document.bbrules.rulesubmit.value = "同 意(" + secs + ")";document.bbrules.rulesubmit.disabled = true;for(i = 1; i <= secs; i++) {        window.setTimeout("update(" + i + ")", i * 1000);}window.setTimeout("timer()", wait);function update(num, value) {        if(num == (wait/1000)) {                document.bbrules.rulesubmit.value = "同 意";        } else {                printnr = (wait / 1000) - num;                document.bbrules.rulesubmit.value = "同 意(" + printnr + ")";        }}function timer() {        document.bbrules.rulesubmit.disabled = false;        document.bbrules.rulesubmit.value = "同 意";}</script> http://hudeyong926.iteye.com/blog/832654
点击表单里的按钮后,这个按钮立即就变灰了
用cs代码的enabled=false在页面提交并返回之前是不会立即有效果的!除非用js。  
      如果是提交表单,可以在submit按纽事件里写document.all.button1.disabled=true;  
  如果是imagebutton,在js里设置按纽的width=0  
   
  <script   language="javascript">  
  //----------只提交一次cmdbutton一般是immagebutton  
  function   submitonce()  
  {  
                    var   cmdbutton=document.all.imagebutton1;  
  if(cmdbutton   !=   null)  
  {  
  cmdbutton.clearattributes();  
  cmdbutton.width=0;  
  }  
  }  
  if(document.all.imagebutton1!=null)  
  document.all.imagebutton1.onclick   =   submitonce;  
  </script>  
  </body>
<html><head><script type="text/javascript">function disable()  {  document.getElementById("mySelect").disabled=true  }function enable()  {  document.getElementById("mySelect").disabled=false  }</script></head><body><form><select id="mySelect">  <option>苹果</option>  <option>桃子</option>  <option>香蕉</option>  <option>桔子</option></select><br /><br /><input type="button"  value="禁用列表"><input type="button"  value="启用列表"></form></body></html> <html><head><script type="text/javascript">function alertId(){var txt="Id: " + document.getElementById("myButton").idtxt=txt + ", type: " + document.getElementById("myButton").typealert(txt)document.getElementById("myButton").disabled=true}</script></head><body><form><button id="myButton" >请点击我!</button></form></body></html> <input type="image" src="http://51js.com/images/default/newtopic.gif"  />
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表