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

How to make a checkbox dim?

Status
Not open for further replies.

joannyk

Programmer
Jan 16, 2001
18
HK
Hi everyone,

I'd like to make a checkbox dim and disable it when click one of the radio buttons on a form. Is there any javascript function will make it? I've tried the blur() but it seemed that's not the suitable one.

Thank you!
 
Set the checkbox's 'disabled' property to true or false depending on whether you want the checkbox disabled or enabled. Like so:

[tt]
<form action=&quot;someaction.asp&quot; method=&quot;get&quot;>
<input name=&quot;checkboxSwitch&quot;
type=&quot;radio&quot; value=&quot;on&quot;
onclick=&quot;if(this.checked){document.forms[0].theCheckbox.disabled=false;}&quot;
checked>
Checkbox On<br>
<input name=&quot;checkboxSwitch&quot;
type=&quot;radio&quot;
value=&quot;off&quot;
onclick=&quot;if(this.checked){document.forms[0].theCheckbox.disabled=true;}&quot;>
Checkbox Off<br>
<input name=&quot;theCheckbox&quot;
type=&quot;checkbox&quot;
value=&quot;Some Value&quot;>
Enable and Disable This Checkbox using the Radio Buttons
</form>
[/tt]
 
Thanks dwarfthrower! It works beautifully.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top