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!

disabling a checkbox

Status
Not open for further replies.

rotsey

Programmer
Nov 23, 2004
135
AU
Does anyone no how to disable a checkbox in javascript.
Have tried

mychk.disabled=true;

?????????

rotsey
 

That should work, assuming mychk correctly points to the checkbox element.

You could do this via an id:

Code:
var mychk = document.getElementById('checkBoxId');

or by its name as a form element:

Code:
var mychk = document.forms['formName'].elements['checkBoxName'];

Hope this helps,
Dan


[tt]D'ya think I got where I am today because I dress like Peter Pan here?[/tt]
[banghead]

 
why is there the need to use js to disable? are you using the variable to be triggered by an action or if statement? html can handle it by simply adding "disabled" within the input tags. Just curious. I'm sure you knew already.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top