Free2Code
 
Time: 2008-11-21, 10:11pm
Greying or disabling FORM components
Subject: Greying or disabling FORM components  ·  Posted: 2006-11-19, 12:14pm
Rank: ? (4278)
Member #: 5260
How do I grey out or disabled a button or checkboxes?

It can be seen, but can't be clicked or checked, unless something else is done first.

I am using HTML, PHP, and when necessary, JavaScript, to create a form, and PHP to interface the data entry or retrieve data with/from a MySQL database table.

Dreams are stories, but my life is just one bad dream. :P
 
  Reply to this ·  Post link ·  Top
Subject: Re: Greying or disabling FORM components  ·  Posted: 2006-11-20, 04:57am
Rank: ? (4821)
Member #: 3416
the xhtml-compliant way is to set the disabled attribute to "disabled" on the checkbox input element:

<input type="checkbox" disabled="disabled" />

if you don't care about xhtml and want to save a few characters, this will do the same thing:

<input type=checkbox disabled>

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top
Subject: Re: Greying or disabling FORM components  ·  Posted: 2006-11-21, 12:34am
Rank: ? (4278)
Member #: 5260
Thanks for responding, misterhaan.

How would I do that interactively on webpage?

Let say there are radiobuttons A and B.

If A is selected, then checkbox C would be disabled. If B is selected, then checkbox C is enabled.

Do I do this in PHP? Or would it be best to be done in JavaScript?

» Post edited 2006-11-21, 12:38am by storyteller.

Dreams are stories, but my life is just one bad dream. :P
 
  Reply to this ·  Post link ·  Top
Subject: Re: Greying or disabling FORM components  ·  Posted: 2006-11-21, 03:18am
Rank: ? (4821)
Member #: 3416
that's probably best done with javascript, but also make sure to check the input on the php side in case someone has javascript disabled.

i'm not sure how you would toggle disabled using javascript, but i would expect an answer to turn up if you search for "javascript checkbox disable"

my mind is like a steel trap! it only hangs on to the big stuff. visit my forums at track7.org
 
  Reply to this ·  Post link ·  Top

Pages: 1

Please login or register to post a reply.

icons