Radio Buttons Lock/UnLock Select List

[Total: 0    Average: 0/5]

This example shows how to have a select list that can be locked (disabled) with the use of radio buttons.

Body Code:

<form name="frmForm"> 
<select name="cboSelect"  onfocus="if (isDis())blur();"> 
          <option value="0" selected>Choose Reason</option> 
          <option value="1">one</option> 
          <option value="2">two</option> 
          <option value="3">three</option> 
        </select> 
Unlocked <input type=radio value="Toggle Disable" checked onclick="lockIt(_F)"   id=radio1 name=radio1> 
Locked   <input type=radio value="Toggle Disable"         onclick="lockIt(_T)" id=radio1 name=radio1> 
<input type=hidden name="lck" value="unlocked"> 
</form> 

<script> 
var _T = "locked";
var _F = "unlocked";
function lockIt(_P) {
  var _L = document.frmForm.lck.value;
  if (_L==_P) return;
  document.frmForm.cboSelect.disabled=(document.frmForm.lck.value=(_L==_F)?_T:_F)==_T; 
}
function isDis() { return (document.frmForm.lck.value==_T); }
</script>

Times Viewed: 0

Leave a Reply

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