Checkbox Problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • George

    Checkbox Problem

    Hi all,

    I have the following code to use checkboxes on my page:
    if instr(Request.f orm("chkWorkTyp e"),"03") then
    response.write( "<td width=""23%"" class=""detaill p""><input
    type=""checkbox "" name=""chkWorkT ype"" value=""03""
    checked=""check "">Exterior </td>")
    else
    response.write( "<td width=""23%"" class=""detaill p""><input
    type=""checkbox "" name=""chkWorkT ype"" value=""03"">Ex terior</td>")
    end if

    if instr(Request.f orm("chkWorkTyp e"),"7A") then
    response.write( "<td width=""25%"" class=""detaill p""><input
    type=""checkbox "" name=""chkWorkT ype"" value=""7A""
    checked=""check "">Ceilings </td>")
    else
    response.write( "<td width=""25%"" class=""detaill p""><input
    type=""checkbox "" name=""chkWorkT ype"" value=""7A"">Ce ilings</td>")
    end if

    There are 14 checkboxes on the form, I only showed the code for two, but
    the remainder of them are coded the same way.

    I am trying have one or more of the boxes checked when the page is
    displayed. I tried to put a value or two in the chkWorkType field:

    chkWorkType= oRS.fields("sht y1") & oRS.fields("sht y2") &
    oRS.fields("sht y3")

    But when I reach the code to display the checkboxes, the chkWorkField
    returns an empty string.

    How can I pre-check some of the boxes?

    Thanks,

    George

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
  • kaeli

    #2
    Re: Checkbox Problem

    In article <417ff1ff$0$249 29$c397aba@news .newsgroups.ws> ,
    anonymous@devde x.com enlightened us with...[color=blue]
    > type=""checkbox "" name=""chkWorkT ype"" value=""7A""
    > checked=""check "">Ceilings </td>")
    > else
    >
    > But when I reach the code to display the checkboxes, the chkWorkField
    > returns an empty string.
    >[/color]

    check should equal "true", not "check". Or just say checked.
    i.e.

    type=""checkbox "" name=""chkWorkT ype"" value=""7A""
    checked=""true" ">Ceilings</td>")

    or
    type=""checkbox "" name=""chkWorkT ype"" value=""7A"" checked>Ceiling s</td>")


    HTH

    --
    --
    ~kaeli~
    Cthulhu saves our souls and redeems them for valuable
    coupons later.



    Comment

    • Michael Winter

      #3
      Re: Checkbox Problem

      On Wed, 27 Oct 2004 16:30:16 -0500, kaeli <tiny_one@NOSPA M.comcast.net>
      wrote:

      [snip]
      [color=blue]
      > check[ed] should equal "true", not "check". Or just say checked.
      > i.e.[/color]

      Actually, boolean attributes like checked and selected should have
      themselves as a value, or no value at all. That is:

      ... checked="checke d"> or ... checked>

      though the latter is preferred[1] as some browsers might not expect a
      value.

      See late in section 3.3.4 - Attribute declarations, Boolean attributes
      (<URL:http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.4.2>). The
      warning at the end is repeated in Appendix B, sub-section 3.4 - Boolean
      attributes (<URL:http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.4>).

      [snip]

      Mike


      [1] Except, I believe, in XHTML where a value is required.

      --
      Michael Winter
      Replace ".invalid" with ".uk" to reply by e-mail.

      Comment

      • McKirahan

        #4
        Re: Checkbox Problem



        "George" <anonymous@devd ex.com> wrote in message
        news:417ff1ff$0 $24929$c397aba@ news.newsgroups .ws...[color=blue]
        > Hi all,
        >
        > I have the following code to use checkboxes on my page:
        > if instr(Request.f orm("chkWorkTyp e"),"03") then
        > response.write( "<td width=""23%"" class=""detaill p""><input
        > type=""checkbox "" name=""chkWorkT ype"" value=""03""
        > checked=""check "">Exterior </td>")
        > else
        > response.write( "<td width=""23%"" class=""detaill p""><input
        > type=""checkbox "" name=""chkWorkT ype"" value=""03"">Ex terior</td>")
        > end if
        >
        > if instr(Request.f orm("chkWorkTyp e"),"7A") then
        > response.write( "<td width=""25%"" class=""detaill p""><input
        > type=""checkbox "" name=""chkWorkT ype"" value=""7A""
        > checked=""check "">Ceilings </td>")
        > else
        > response.write( "<td width=""25%"" class=""detaill p""><input
        > type=""checkbox "" name=""chkWorkT ype"" value=""7A"">Ce ilings</td>")
        > end if
        >
        > There are 14 checkboxes on the form, I only showed the code for two, but
        > the remainder of them are coded the same way.
        >
        > I am trying have one or more of the boxes checked when the page is
        > displayed. I tried to put a value or two in the chkWorkType field:
        >
        > chkWorkType= oRS.fields("sht y1") & oRS.fields("sht y2") &
        > oRS.fields("sht y3")
        >
        > But when I reach the code to display the checkboxes, the chkWorkField
        > returns an empty string.
        >
        > How can I pre-check some of the boxes?
        >
        > Thanks,
        >
        > George
        >
        > *** Sent via Developersdex http://www.developersdex.com ***
        > Don't just participate in USENET...get rewarded for it![/color]


        Comment

        • Grant Wagner

          #5
          Re: Checkbox Problem

          kaeli wrote:
          [color=blue]
          > check should equal "true", not "check". Or just say checked.
          > i.e.
          >
          > type=""checkbox "" name=""chkWorkT ype"" value=""7A""
          > checked=""true" ">Ceilings</td>")[/color]

          OT but doesn't this DTD entry: <url:
          http://www.w3.org/TR/REC-html40/sgml/dtd.html />

          <!ATTLIST INPUT
          %attrs; -- %coreattrs, %i18n, %events --
          type %InputType; TEXT -- what kind of widget is needed --
          name CDATA #IMPLIED -- submit as part of form --
          value CDATA #IMPLIED -- Specify for radio buttons and
          checkboxes --
          checked (checked) #IMPLIED -- for radio buttons and check boxes --
          disabled (disabled) #IMPLIED -- unavailable in this context --
          readonly (readonly) #IMPLIED -- for text and passwd --
          size CDATA #IMPLIED -- specific to each type of field --
          maxlength NUMBER #IMPLIED -- max chars for text fields --
          src %URI; #IMPLIED -- for fields with images --
          alt CDATA #IMPLIED -- short description --
          usemap %URI; #IMPLIED -- use client-side image map --
          ismap (ismap) #IMPLIED -- use server-side image map --
          tabindex NUMBER #IMPLIED -- position in tabbing order --
          accesskey %Character; #IMPLIED -- accessibility key character --
          onfocus %Script; #IMPLIED -- the element got the focus --
          onblur %Script; #IMPLIED -- the element lost the focus --
          onselect %Script; #IMPLIED -- some text was selected --
          onchange %Script; #IMPLIED -- the element value was changed --
          accept %ContentTypes; #IMPLIED -- list of MIME types for file upload --

          %reserved; -- reserved for possible future use --[color=blue]
          >[/color]

          Indicate that the only valid value for checked is "checked"? Just as the only
          valid value for disabled is "disabled" and readonly is "readonly" etc?

          ie-

          <input type="checkbox"
          ...
          readonly="reado nly"
          disabled="disab led"
          checked="checke d">

          or

          <td nowrap="nowrap" class="nr">
          <!-- deprecated, but necessary since NS4 doesn't support
          td.nr { white-space: nowrap; } -->

          Or am I reading the specification wrong?

          Anyway, that's the way I was taught and the way I do it. For attributes that
          have no "value", I supply a quoted value equal to the attribute name (I'm
          trying to think of any cases where I do not do this, there may be some but not
          many).

          --
          Grant Wagner <gwagner@agrico reunited.com>
          comp.lang.javas cript FAQ - http://jibbering.com/faq

          Comment

          • kaeli

            #6
            Re: Checkbox Problem

            In article <41811689.FBEEF 311@agricoreuni ted.com>, gwagner@agricor eunited.com
            enlightened us with...[color=blue]
            >
            > Anyway, that's the way I was taught and the way I do it. For attributes that
            > have no "value", I supply a quoted value equal to the attribute name (I'm
            > trying to think of any cases where I do not do this, there may be some but not
            > many).
            >[/color]

            Sorry, yeah, I stand corrected.
            I always just use "checked" standalone, myself.
            IIRC, if you get the value of a checkbox from a form, isn't it "true" if it's
            checked? I think that's what I was thinking of.

            OP needs to fix 'checked="check "' to 'checked="check ed"'.

            --
            --
            ~kaeli~
            Shotgun wedding: A case of wife or death.



            Comment

            • Michael Winter

              #7
              Re: Checkbox Problem

              On Thu, 28 Oct 2004 13:16:20 -0500, kaeli <tiny_one@NOSPA M.comcast.net>
              wrote:

              [snip]
              [color=blue]
              > IIRC, if you get the value of a checkbox from a form, isn't it "true" if
              > it's checked? [...][/color]

              It's value is exactly the same as every other form control: the content of
              the value attribute. The checked state of a checkbox only determines
              whether the control is successful, and therefore whether its value is
              submitted along with the rest of the form data.

              If checkbox is unchecked, it still has the value specified in the value
              attribute, but it won't be sent to the server.
              [color=blue]
              > OP needs to fix 'checked="check "' to 'checked="check ed"'.[/color]

              Or just 'checked'.

              Mike

              --
              Michael Winter
              Replace ".invalid" with ".uk" to reply by e-mail.

              Comment

              • kaeli

                #8
                Re: Checkbox Problem

                In article <opsglfdebkx13k vk@atlantis>, M.Winter@blueyo nder.co.invalid
                enlightened us with...[color=blue]
                >[color=green]
                > > IIRC, if you get the value of a checkbox from a form, isn't it "true" if
                > > it's checked? [...][/color]
                >
                > It's value is exactly the same as every other form control: the content of
                > the value attribute. The checked state of a checkbox only determines
                > whether the control is successful, and therefore whether its value is
                > submitted along with the rest of the form data.
                >
                > If checkbox is unchecked, it still has the value specified in the value
                > attribute, but it won't be sent to the server.
                >[/color]

                Ah, okay, thanks.

                --
                --
                ~kaeli~
                Support your local medical examiner: die strangely!



                Comment

                Working...