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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show/HIde text area based on radion button choice

Status
Not open for further replies.

mat41

Programmer
Mar 7, 2004
91
AU
I wish to provide two radio buttons to the following question:
"Can you safely manage your capability requirements?" [Yes] or [No]

If the user clicks [No] I wish for two text areas to become visible. Yes will be ticked by default, no action is required in this circumstance.

TYIA
 
Apart from styling, something like this.
[tt]
<head>
<script language="javascript">
function dostyle() {
var oform=document.formname;
if (oform.rdbtn[0].checked) {
oform.textarea0.style.display="none";
oform.textarea1.style.display="none";
} else {
oform.textarea0.style.display="inline";
oform.textarea1.style.display="inline";
/*
oform.textarea0.style.display="block";
oform.textarea1.style.display="block";
*/
}
}
window.onload=dostyle;
</script>
</head>
<body>
<form name="formname">
<div><span>Can you safely manage your capability requirement?</span>
<input type="radio" name="rdbtn" value="yes" checked="checked" onclick="dostyle()" />yes
<input type="radio" name="rdbtn" value="no" onclick="dostyle()" />no
</div>
<div style="float:right;">
<textarea name="textarea0" style="overflow:auto;height:10em;">textarea0</textarea>
<textarea name="textarea1" style="overflow:auto;height:10em;">textarea1</textarea>
</div>
<div>other contents</div>
</form>
</body>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top