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

Tricky Forms question

Status
Not open for further replies.

JayBuys

Programmer
Jun 18, 2001
17
0
0
US
I'd to have a form with certain elements that remain disabled until a user checks a certain box.
Example.. there's a checkbox and a textfield ont the screen. The textfield is disabled. Once the user checks the checkbox, the textfield is enabled.
I'm pretty sure this is possible but am not sure how to do it. Any help is appreciated.
Thank you,
J
 
Here's a very rough example, but it demonstrates what you want.
Code:
<html>
<head>
<title>Enable/Disable</title>
<script>
function checkMe() {
  if (document.forms.f1.c1.checked)
     document.forms.f1.t1.disabled=false;
  else
     document.forms.f1.t1.disabled=true;
}
</script>

</head>
<body>

<form name=&quot;f1&quot;>
<input type=&quot;checkbox&quot; name=&quot;c1&quot; onClick=&quot;checkMe()&quot;>
<br>
<input type=&quot;text&quot; width=&quot;20&quot; name=&quot;t1&quot;>
</form>

<script>
// disable the textbox once page has loaded
document.forms.f1.t1.disabled=true;
</script>

</body>
</html>
Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top