日期:2014-05-16  浏览次数:20521 次

一个文本框,onclick事情,如何控制第一次单击有效,以后再单击失效
一个文本框,onclick事情,如何控制第一次单击有效,以后再单击失效,就是不执行任何操作




------解决方案--------------------
<input type= "text " onclick= "this.disabled=true " />
------解决方案--------------------
onclick= "alert( 'a ');this.onclick=function(){return;} "
------解决方案--------------------

文本框1: <input name= <%= "Txt_key1_ "&Rs( "id ")%> type= "text " id= <%= "Txt_key1_ "&Rs( "id ")%> size= "8 " maxlength= "20 " onchange= "document.getElementById( ' <%= "Txt_msg_ "&Rs( "id ")%> ').disable=false; ">

文本框2: <input name= <%= "Txt_key2_ "&Rs( "id ")%> type= "text " id= <%= "Txt_key2_ "&Rs( "id ")%> size= "8 " maxlength= "20 " onchange= "document.getElementById( ' <%= "Txt_msg_ "&Rs( "id ")%> ').disable=false; ">

广本框3: <input name= " <%= "Txt_msg_ "&Rs( "id ")%> " type= "text " id= " <%= "Txt_msg_ "&Rs( "id ")%> " size= "90 " maxlength= "180 " onClick= "average( <%=Rs( "id ")%> );this.disable=true; ">
------解决方案--------------------
很简单啦! 在js里设一个全局变量,假如说是var text3_ok=true; 那么当你执行文本框3的onclick方法时先判断text3_ok是否为true,哪果为true,继续执行你的方法,否则不执行.在你第一次执行方法时,在方法体的最后加上text3_ok=false; 这样就可以做到只能执行一次的效果了.
其它同上. 你的文本框互机有关联,你可以在相关联的方法内将所关联的 "开关 "(如text3_ok)开启或关闭.这样就能达到效果了!