Disable Checkbox

[Total: 0    Average: 0/5]

This example shows how to lock a checkbox and have it work for IE55 NS47 and NS6.

Body Code:

 <form name=exf1>
 <input type="checkbox" name="c1" value="check me 1" onclick="return doIt(1)">1<BR>
 <input type=hidden name=h1 value=0>
 <input type="checkbox" name="c2" value="check me 2" onclick="return doIt(2)">2<BR>
 <input type=hidden name=h2 value=0>
 <input type="checkbox" name="c3" value="check me 3" onclick="return doIt(3)">3<BR>
 <input type=hidden name=h3 value=0>
 </form>
 <script>
 var U=0;L=1;// (U)nlocked & (L)ocked
 /* if doIt returns false it will cancel the click */
 function doIt(_v)
 {
   var _returnValue = eval("document.exf1.h"+_v+".value==0?true:false")
   if(eval("document.exf1.c"+_v+".checked"))
   {
     if(_v==1){unlock(2);unlock(3);}
     if(_v==2){lock(3);}
     if(_v==3){lock(2);}
   }
   else
   {
     if(_v==1){whipe(2);whipe(3);unlock(2);unlock(3);}
 	if(_v==2){unlock(3);}
 	if(_v==3){unlock(2);}
   }
   return(_returnValue);
 }
 function lock(_v)
 {
   eval("document.exf1.c"+_v+".disabled=true");/* IE thing */
   eval("document.exf1.h"+_v+".value=L");
 }
 function unlock(_v)
 {
   eval("document.exf1.c"+_v+".disabled=false");/* IE thing */
   eval("document.exf1.h"+_v+".value=U");
 }
 function whipe(_v)
 {
   eval("document.exf1.c"+_v+".checked=false");
 }
 </script>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *