Link to home
Start Free TrialLog in
Avatar of hualing
hualing

asked on

How to make a check box disable?

<input type=checkbox name=mimi>

Can I  make mimi disabled so that no one can uncheck it?

How can I accomplish this by Javascript?
 

Thanks
ASKER CERTIFIED SOLUTION
Avatar of matrix717
matrix717

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of knightEknight
actually, that should be:

document.nameofmyform.mimi.disabled=true;

.... and for Netscape, you must do this:

<INPUT type='checkbox' name='mimi' onFocus='this.blur();'>
Avatar of hualing
hualing

ASKER

Dear you,
You suggestion is work.
But now I want a button click to arouse the input checkbox disabled.

I tried this:
<input type=button nclick="document.forms[0].mimi=this.blur();">  
but failed.

I need a smooth code work well on both IE & NN

THANKS !
If you need it to be disabled when the page loads, you need to tell netscape it is:
<body onLoad="document.myForm.mimi.disabled=true">

<FORM NAME="myForm">
<INPUT NAME="mimi" TYPE="checkbox" onClick="if (this.disabled) this.checked=false">
<INPUT TYPE="button" onClick="this.form.mimi.disabled=true">
</FORM>

it will work in both browsers but be more visible in IE.

Michel

<INPUT NAME="mimi" TYPE="checkbox" disabled>
TYoung - that is how to initialise it in IE only and will disable it from the load of the page.
My script will disable the checkbox at will and work in Netscape too

Michel