Locked Checkboxes

[Total: 0    Average: 0/5]

This example shows how to have checkboxes locked.

Body Code:

<form name=exf1>
<input type="checkbox" name="c1" value="check me 1" onclick=doIt(1)>1<BR>
<input type=hidden name=h1 value=0>
<input type="checkbox" name="c2" value="check me 2" onclick=doIt(2)>2<BR>
<input type=hidden name=h2 value=0>
<input type="checkbox" name="c3" value="check me 3" onclick=doIt(3)>3<BR>
<input type=hidden name=h3 value=0>
</form>
<script>
var U=0;L=1; // (U)nlocked & (L)ocked
function doIt(_v)
{
  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);}
  }
}
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 *