Radio button Hide/Show TextBox

[Total: 0    Average: 0/5]

This shows how to have a radio button hide or show another component of that same form.

Body Code:

Notice how the NS version hides the "layers" not the "divs".<BR>
<layer id=d1>TEST TEXT 1</layer><BR>
<layer id=d2>TEST TEXT 2</layer><BR>
<layer id=d3>TEST TEXT 3</layer><BR>
<form name="f1">
<div id=d1>T1:<input type=text name=t1 value="t1"><BR></div>
<div id=d2>T1:<input type=text name=t2 value="t2"><BR></div>
<div id=d3>T1:<input type=text name=t3 value="t3"><BR></div>
Hide T1: <input type=radio name="r1" value='Hide T1' onclick='_h(1,true)'><BR>
Hide T2: <input type=radio name="r1" value='Hide T1' onclick='_h(2,true)'><BR>
Hide T3: <input type=radio name="r1" value='Hide T1' onclick='_h(3,true)'><BR>
Show T1: <input type=radio name="r1" value='Show T1' onclick='_h(1,false)'><BR>
Show T2: <input type=radio name="r1" value='Show T1' onclick='_h(2,false)'><BR>
Show T3: <input type=radio name="r1" value='Show T1' onclick='_h(3,false)'><BR>
</form>
<script>
var isIE=document.all?true:false;
var isNS4=document.layers?true:false;
var isDOM=document.getElementById?true:false;

var _a = document.all?"all.":"layers.";
var _b = document.all?"style.":"";
document.f1.t1.hidden=true;
function _h(_i,_hs)
{
  var _HS=_hs?"hidden":"visible";
  if(isDOM)      document.getElementById("t"+_i).style.visibility=_HS;
  else if(isIE)  eval("document.all.t"+_i+".style.visibility='"+_HS+"'");
  else if(isNS4) eval("document.all.d"+_i+".style.visibility='"+_HS+"'")
}
</script>

Times Viewed: 3

Leave a Reply

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