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

checkbox readonly

Status
Not open for further replies.

jianbo

Programmer
Dec 19, 2001
78
US
Can I make a checkbox readonly? User can't check it?
 
jianbo:

To make a checkbox readonly use the following bit of code in the onClick event of the checkbox:

OnClick="if (true == true) return false;"

Of course where the true == true you would put your variable to check against and if it is readonly, the user would not be able to check it.

Hope this helps,
Patrick

 
A checkbox readonly?
Don't you mean disabled?
try this.

<input type=&quot;checkbox&quot; name=&quot;checkbox_1&quot; value=&quot;1&quot; disabled checked>
<input type=&quot;checkbox&quot; name=&quot;checkbox_2&quot; value=&quot;2&quot; disabled >


Checkbox_1 will show the check mark, checkbox_2 will show the box empty.





grtfercho çB^]\..
 
I thought READONLY, DISABLED were only for text type. Thanks grtfercho.
While I prefer PatrickGreen's method, my checkbox will not become greybox. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top