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

Disable edit box?

Status
Not open for further replies.

cyprus106

Programmer
Apr 30, 2001
654
Is it possible to disable an edit box and the submit button associated with it in a form? If so how do you do it? and can it just be toggled on and off?

Thanks!

Cyprus
 
Yep, through the 'disabled' attribute and, yep.

Code:
<html>
<head>
<script>
//This function toggles the 'disabled' attribute of the text box
Code:
function doToggle(){
 document.all.wax.disabled = !document.all.wax.disabled;
 if(document.all.wax.disabled){
  document.all.toggle.value = 'Wax On';
 }
 else{
  document.all.toggle.value = 'Wax Off';
 }
}
</script>
</head>
<body>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;>
<!-- Here is how you specify a form element to be disabled from the start -->
Code:
  <input name=&quot;wax&quot; value=&quot;Wax&quot; type=&quot;text&quot; disabled=&quot;true&quot;>
  <input name=&quot;toggle&quot; type=&quot;button&quot; value=&quot;Wax On&quot; onClick=&quot;doToggle()&quot;>
</form>
</body>
</html>

The 'disabled' attribute can be specified for all form elements.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top