readonly checkbox

Posted on 2006-03-20
Last Modified: 2012-05-05
Hi all
I'm just wondering if there is away to display a "readonly" checkbox??

Thanks in advance.
Question by:lina000
    LVL 49

    Expert Comment

    You can try using disabled="disabled", don't think readonly="readonly" will do the trick.

    With disabled-property however, the checkboxs value will also not be submitted along with the form, so when using that one, you should add a hidden textfield if you need a value to be submitted.

    LVL 28

    Expert Comment

    by:Pravin Asar
    If you want user not to be able to uncheck the checkbox, you do always do following.

    I am assuming, you want to inform user that her has selected certain option.

    <p><input type="checkbox" value="1" onClick="this.checked=true;" checked >Check Box

    This one set the box as checked always.

    LVL 7

    Expert Comment

    enabled = false
    LVL 75

    Accepted Solution

    In what browser world do you have an attribute called enabled?

    How about this, assuming you checked in on the server:

    <input type="checkbox" onClick="this.checked=this.defaultChecked" <%= (isChecked)? " checked":"" %>>
    LVL 11

    Expert Comment

    Here you go...

    <title>mvan - Q_21772120 solution</title>

    <script language="JavaScript">

    function lockBox() {


    <body onLoad="lockBox();">
    <input type="checkbox" name=name1 value="1" checked >Static Check Box<br>
    <input type="checkbox" name=name2 value="2" >Static Check Box<br>
    <input type="checkbox" name=name3 value="3" >Active Check Box<br>

    LVL 75

    Expert Comment

    by:Michel Plungjan
    document.forms is an array, not a collection

    LVL 11

    Expert Comment


    Thank you.  

    In IE, either worked: .forms(0) or .forms[0] .  MS let me get away with sloppy code, I guess.  : 0

    I don't have FF on this computer, so I can't test it at this time.


    Author Comment

    Thanks all for replying!
    The thing is that I need to display the checkbox not disabling it! because sometimes the user needs to print the form and in the same time I don't want him to check or uncheck the box so basically it will be used to displaying and later printing!!
    LVL 11

    Expert Comment

    ... so you needed the image of a checkbox (probably unchecked) that the user could not check on-line, so they could print it out (unchecked) and fill in the paper copy.  I guess the disabled checkbox did not do that for you, because it became greyed out?  Oh well...


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
    In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now