Disable checkbox

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have a checkbox that I set by php code to be either "checked" or "".
I want to disable the ability of the user to check or uncheck it.  I
tried "readonly", but that didn't work.  Any suggestions?

Re: Disable checkbox

sheldo...@gmail.com wrote:
Quoted text here. Click to load it


Try the first link that comes up.

Re: Disable checkbox

I think it is disabled="true" that you want to use. That should work, I

Re: Disable checkbox

Michael wrote:
Quoted text here. Click to load it

HTML style:
<input type="checkbox" name="foo" disabled>

XHTML style:
<input type="checkbox" name="foo" disabled="disabled"/>

Re: Disable checkbox

Quoted text here. Click to load it

The "disabled" worked.  What is that trailing slash for?  

Re: Disable checkbox

Shelly wrote:
Quoted text here. Click to load it

XHTML compliance.  In XHTML, all tags must have matching closing tags.
Some tags are "self-closing" however (like <input>) so instead of a
</input> you just leave a trailing / to close it.

Re: Disable checkbox

ZeldorBlat schrieb:
Quoted text here. Click to load it

Disabled and readonly are different things - IIRC the values of readonly  
elements are submitted while the values of disabled elements are not. So  
the OP could run into problems in the case of:

<input type="checkbox" name="foo" value="1" checked disabled>

In this case readonly is definitely the correct attribute. Internet  
Explorer seems not to support readonly, though, which is a bug.

Anyway as this is not a PHP topic there might more detailed information  
to be found in an HTML group.


Re: Disable checkbox

In my case it is "disabled".  The reason is that I want to show which
uploads have been done as indicated by the presence of the file on the
server.  I dynamically put in "disabled" or leave it blank.  If it is
disabled, I set it as checked.  I do this by checking for the presence
of the files on the server and setting session variables if they are
there.  In other words, the check box is not a "choice".  Rather, it is
an indicator of completion.

When the user does the submit for the entire transaction, I first check
to see if all the required uploads are present (not all are required),
and then process the information. (All that is done is PHP).  If they
are not all there, I present the user with information about the what
is missing.

When he uploads the missing file, the checkbox is set as checked and


Site Timeline