Saturday, February 19, 2011

when click a radio button display related text boxes

<html>
<head>
<script language='javascript'>
function display(){   
     if(document.frmRadio.selType[0].checked){
       document.getElementById('div1').style.display = 'block';
       document.getElementById('div2').style.display = 'block' ;
     }
     else{
       document.getElementById('div2').style.display =  'none';
       document.getElementById('div1').style.display = 'block';
     }       
}
</script>
</head>
<body>
<form name='frmRadio'>
<tr><td><input type=radio name='selType' onclick='display()'> Display dropdown & textbox</td></tr>
<tr><td><input type=radio name='selType' onclick='display()'> Display Textbox Only</td></tr>
<tr height='30'><td>&nbsp;</td></tr>
<div id='div1' style=display:none>
<tr>
  <td><input type='text' name='txtName'></td>
</tr>
</div>
<div id='div2' style=display:none>
<tr>
  <td>
      <select name='selOption'>
         <option value='A'>A</option>
         <option value='B'>B</option>
      </select>
  </td>
</tr>
</div>
</form>
</body>
</html>

0 comments:

Post a Comment