Disable checkbox

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sheldonlg@gmail.com

    Disable checkbox

    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?

  • ZeldorBlat

    #2
    Re: Disable checkbox


    sheldo...@gmail .com wrote:[color=blue]
    > 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?[/color]

    <http://www.google.com/search?q=disabl e+checkbox>

    Try the first link that comes up.

    Comment

    • Michael

      #3
      Re: Disable checkbox

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

      Comment

      • ZeldorBlat

        #4
        Re: Disable checkbox


        Michael wrote:[color=blue]
        > I think it is disabled="true" that you want to use. That should work, I
        > think.[/color]

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

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

        Comment

        • Shelly

          #5
          Re: Disable checkbox


          "ZeldorBlat " <zeldorblat@gma il.com> wrote in message
          news:1140123120 .897872.275040@ z14g2000cwz.goo glegroups.com.. .[color=blue]
          >
          > Michael wrote:[color=green]
          >> I think it is disabled="true" that you want to use. That should work, I
          >> think.[/color]
          >
          > HTML style:
          > <input type="checkbox" name="foo" disabled>
          >
          > XHTML style:
          > <input type="checkbox" name="foo" disabled="disab led"/>
          >[/color]

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


          Comment

          • ZeldorBlat

            #6
            Re: Disable checkbox


            Shelly wrote:[color=blue]
            > "ZeldorBlat " <zeldorblat@gma il.com> wrote in message
            > news:1140123120 .897872.275040@ z14g2000cwz.goo glegroups.com.. .[color=green]
            > > HTML style:
            > > <input type="checkbox" name="foo" disabled>
            > >
            > > XHTML style:
            > > <input type="checkbox" name="foo" disabled="disab led"/>
            > >[/color]
            >
            > The "disabled" worked. What is that trailing slash for?[/color]

            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.

            Comment

            • Markus Ernst

              #7
              Re: Disable checkbox

              ZeldorBlat schrieb:[color=blue]
              > Michael wrote:
              >[color=green]
              >>I think it is disabled="true" that you want to use. That should work, I
              >>think.[/color]
              >
              >
              > HTML style:
              > <input type="checkbox" name="foo" disabled>
              >
              > XHTML style:
              > <input type="checkbox" name="foo" disabled="disab led"/>
              >[/color]

              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.

              --
              Markus

              Comment

              • sheldonlg@gmail.com

                #8
                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
                disabled.

                Shelly

                Comment

                Working...