Results 1 to 5 of 5

Thread: checkbox question (HTML)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    18

    checkbox question (HTML)

    i'm not sure if this is the right forum for it. my question is,
    how can I disable a checkbox on html page using either css(preferably) or any way. i used 'disabled' attribute. but it greys out the check box. I dont want it to look grey.
    and plz be quick.

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    total hack
    Code:
    <input type="checkbox" onclick="this.checked=false">

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Aug 2000
    Posts
    18
    great:

    i would use:

    <input type="checkbox" onclick="this.checked= !this.checked">

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    thats worked out as quite an elegant solution,
    but users should have some way of knowing it's disabled and not just click mindlessly.

  5. #5
    Frenzied Member Rick Bull's Avatar
    Join Date
    Apr 2002
    Location
    England
    Posts
    1,444
    By the way I think you should be able to use the disabled pseudo class (just going from memory, so I'm not sure if I'm right), but I have a suspicion IE won't support it:

    Code:
    input:disabled {
      background:white;
      color:black;
    }
    if it isn't in the CSS 2 specs I think it's in 3, but you can use this (again won't work in IE)

    Code:
    input[disabled] {
      background:white;
      color:black;
    }

    Which is preferable to JavaScript, as not every has it (10-15%).
    Last edited by Rick Bull; Jan 10th, 2003 at 08:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width