Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hiding the Text box field!

Status
Not open for further replies.

micjohnson

Programmer
Nov 9, 2000
86
US
Hi there!

i have two radio buttons Yes, No and drop down box(<select>), text field.

It is like

Yes(Radio button) ---> Select box

No(Radio button) ---> Text box.


My aim is, if i chose &quot;Yes&quot;, I can activate the &quot;Select box&quot;. At the same time the &quot;text box&quot; should not accept any values.

if i chose &quot;No&quot;, I can accept the values in the &quot;text&quot; box. At the same time the &quot;Select box&quot; should not be activate.

Guide me.

Thanx
 
Hey micjohnson,

You can probably find out more about this in the javascript forums but this should get you started:

<script language=&quot;javascript&quot;>
function enabling(){

document.mine.Selct.disabled = true;
document.mine.Selct.enabled = false;
document.mine.Entr.disabled = false;
document.mine.Entr.enabled = true;
return false;

}
function disabling(){

document.mine.Selct.disabled = false;
document.mine.Selct.enabled = true;
document.mine.Entr.disabled = true;
document.mine.Entr.enabled = false;
return false;
}
</script>

<FORM name=mine action=here.cfm method=post>
<table>
<tr><td>
<input type=radio name=chk onClick='disabling()'></td>
<td>
<Select name=Selct >
<OPTION Value=1>1</OPTION>
<OPTION Value=2>2</OPTION>
<OPTION Value=3>3</OPTION>
<OPTION Value=4>4</OPTION>
</Select>
</td>
</tr>
<tr>
<td>
<input type=radio name=chk onClick='enabling()'></td>
<td>
<input type=Text name=Entr size=30></td>
</tr>
</table>
</FORM>

I tried this and it works fine on IE. I think it doesn't work on Netscape but I think there is another way to do it for netscape maybe 'blur'? Anyway, check with the Javascript guys they will know for sure. I was having trouble getting the enable/disable to be consistent that's why I used both. Seems ok, but I'm no Javascript Guru.

Have fun...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top