Radio buttons do not appear checked

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

    #1

    Radio buttons do not appear checked

    <b>Agency 4</b>
    <input type="radio" name="permissio n[4]" value="1" checked> Yes
    <input type="radio" name="permissio n[4]" value="0" > No
    <br>
    <b>Agency 5</b>
    <input type="radio" name="permissio n[5]" value="1" checked> Yes
    <input type="radio" name="permissio n[5]" value="0" > No
    <br>


    I have it set up this way but upon viewing in the browser none of the
    radio buttons appear checked.

    By the way the radio button names MUST remain in the PHP array format
    as they will be referenced EXACTLY like that by PHP on the server end.
    Sorry can't change that.

    What can I do?

    Phil
  • Mike

    #2
    Re: Radio buttons do not appear checked

    I think what you want want is to change your input type to "checkbox"

    Cheers,
    Mike

    "Phil Powell" <soazine@erols. com> wrote in message
    news:1cdca2a7.0 309301241.4556c ec5@posting.goo gle.com...[color=blue]
    > <b>Agency 4</b>
    > <input type="radio" name="permissio n[4]" value="1" checked> Yes
    > <input type="radio" name="permissio n[4]" value="0" > No
    > <br>
    > <b>Agency 5</b>
    > <input type="radio" name="permissio n[5]" value="1" checked> Yes
    > <input type="radio" name="permissio n[5]" value="0" > No
    > <br>
    >
    >
    > I have it set up this way but upon viewing in the browser none of the
    > radio buttons appear checked.
    >
    > By the way the radio button names MUST remain in the PHP array format
    > as they will be referenced EXACTLY like that by PHP on the server end.
    > Sorry can't change that.
    >
    > What can I do?
    >
    > Phil[/color]


    Comment

    • Andy Hassall

      #3
      Re: Radio buttons do not appear checked

      On 30 Sep 2003 13:41:13 -0700, soazine@erols.c om (Phil Powell) wrote:
      [color=blue]
      ><b>Agency 4</b>
      > <input type="radio" name="permissio n[4]" value="1" checked> Yes
      > <input type="radio" name="permissio n[4]" value="0" > No
      > <br>
      > <b>Agency 5</b>
      > <input type="radio" name="permissio n[5]" value="1" checked> Yes
      > <input type="radio" name="permissio n[5]" value="0" > No
      > <br>
      >
      >
      >I have it set up this way but upon viewing in the browser none of the
      >radio buttons appear checked.[/color]

      Works for me, on IE6 and Mozilla 1.4. What browser are you using?

      --
      Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
      Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

      Comment

      • Hywel Jenkins

        #4
        Re: Radio buttons do not appear checked

        In article <1cdca2a7.03093 01241.4556cec5@ posting.google. com>,
        soazine@erols.c om says...[color=blue]
        > <b>Agency 4</b>
        > <input type="radio" name="permissio n[4]" value="1" checked> Yes
        > <input type="radio" name="permissio n[4]" value="0" > No
        > <br>
        > <b>Agency 5</b>
        > <input type="radio" name="permissio n[5]" value="1" checked> Yes
        > <input type="radio" name="permissio n[5]" value="0" > No
        > <br>
        >
        > I have it set up this way but upon viewing in the browser none of the
        > radio buttons appear checked.
        >
        > By the way the radio button names MUST remain in the PHP array format
        > as they will be referenced EXACTLY like that by PHP on the server end.
        > Sorry can't change that.[/color]

        Works for me in IE6 and Firebird 0.6.1

        [color=blue]
        > What can I do?[/color]

        Find a more appropriate group. This is neither a PHP nor JavaScript
        issue.

        --
        Hywel I do not eat quiche


        Comment

        • Andy Hassall

          #5
          Re: Radio buttons do not appear checked

          On Tue, 30 Sep 2003 23:48:57 +0300, "Mike" <noemail@noemai l.com> wrote:
          [color=blue]
          >"Phil Powell" <soazine@erols. com> wrote in message
          >news:1cdca2a7. 0309301241.4556 cec5@posting.go ogle.com...[color=green]
          >> <b>Agency 4</b>
          >> <input type="radio" name="permissio n[4]" value="1" checked> Yes
          >> <input type="radio" name="permissio n[4]" value="0" > No[/color]
          >
          >I think what you want want is to change your input type to "checkbox"[/color]

          Why? How can the reply be 'Yes' and 'No' at the same time? Radio looks the
          sensible choice here.

          --
          Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
          Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

          Comment

          • VK

            #6
            Re: Radio buttons do not appear checked

            Any name has to start with a letter and consist of any combination of
            letters, numbers and underscores to the total length of 255 characters.
            (Where the "letter" means any character from the a-z, A-Z range)
            This is a vary basic of any programming language including JavaScript.
            Otherwise you are on the merci of a particular system (browser) - will it
            eat your wrong names or not.

            Phil Powell <soazine@erols. com> wrote in message
            news:1cdca2a7.0 309301241.4556c ec5@posting.goo gle.com...[color=blue]
            > <b>Agency 4</b>
            > <input type="radio" name="permissio n[4]" value="1" checked> Yes
            > <input type="radio" name="permissio n[4]" value="0" > No
            > <br>
            > <b>Agency 5</b>
            > <input type="radio" name="permissio n[5]" value="1" checked> Yes
            > <input type="radio" name="permissio n[5]" value="0" > No
            > <br>
            >
            >
            > I have it set up this way but upon viewing in the browser none of the
            > radio buttons appear checked.
            >
            > By the way the radio button names MUST remain in the PHP array format
            > as they will be referenced EXACTLY like that by PHP on the server end.
            > Sorry can't change that.
            >
            > What can I do?
            >
            > Phil[/color]


            Comment

            • Andy Hassall

              #7
              Re: Radio buttons do not appear checked

              On Wed, 1 Oct 2003 01:02:33 +0200, "VK" <schools_ring@y ahoo.com> wrote:
              [color=blue]
              >Phil Powell <soazine@erols. com> wrote in message
              >news:1cdca2a7. 0309301241.4556 cec5@posting.go ogle.com...[color=green]
              >> <b>Agency 4</b>
              >> <input type="radio" name="permissio n[4]" value="1" checked> Yes
              >> <input type="radio" name="permissio n[4]" value="0" > No
              >> <br>
              >> <b>Agency 5</b>
              >> <input type="radio" name="permissio n[5]" value="1" checked> Yes
              >> <input type="radio" name="permissio n[5]" value="0" > No
              >> <br>
              >>
              >> I have it set up this way but upon viewing in the browser none of the
              >> radio buttons appear checked.
              >>
              >> By the way the radio button names MUST remain in the PHP array format
              >> as they will be referenced EXACTLY like that by PHP on the server end.
              >> Sorry can't change that.[/color]
              >
              >Any name has to start with a letter and consist of any combination of
              >letters, numbers and underscores to the total length of 255 characters.
              >(Where the "letter" means any character from the a-z, A-Z range)[/color]

              Not true, see below.
              [color=blue]
              >This is a vary basic of any programming language including JavaScript.
              >Otherwise you are on the merci of a particular system (browser) - will it
              >eat your wrong names or not.[/color]

              permission[4] is a valid value for the name attribute of the <input> element,
              as described in the HTML specification.

              The input element's name attribute is of type CDATA with no further
              restrictions defined by the specification.

              The last discussion I remember of this ended up with these messages:
              (very long URL - your newsreader may wrap it)



              The message linked says [] in an input name is invalid, the replies disprove
              this.

              Individual languages may have trouble with non-alphabetic characters as part
              of a name attribute, but it's valid HTML and so should really be possible to
              deal with it in any language working with HTML.

              (BTW I'm not sure why this is posted to either of the PHP or JavaScript
              newsgroups, since the only posted content is in valid HTML)

              --
              Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
              Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

              Comment

              • Geoff Berrow

                #8
                Re: Radio buttons do not appear checked

                I noticed that Message-ID: <3f7a0bda$0$128 72$9b622d9e@new s.freenet.de>
                from VK contained the following:
                [color=blue]
                >Any name has to start with a letter and consist of any combination of
                >letters, numbers and underscores to the total length of 255 characters.
                >(Where the "letter" means any character from the a-z, A-Z range)
                >This is a vary basic of any programming language including JavaScript.
                >Otherwise you are on the merci of a particular system (browser) - will it
                >eat your wrong names or not.[/color]

                Wish I'd read that earlier. I spent three hours today trying to figure
                out a simple javascript problem until I figured out I could not call my
                checkboxes 1,2,3, etc



                --
                Geoff Berrow
                It's only Usenet, no one dies.
                My opinions, not the committee's, mine.
                Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                Comment

                • Richard Cornford

                  #9
                  Re: Radio buttons do not appear checked

                  "Andy Hassall" <andy@andyh.co. uk> wrote in message
                  news:n63knvgnp4 eb5kpvpv09qjvtn ca5r37a3n@4ax.c om...[color=blue]
                  > On Wed, 1 Oct 2003 01:02:33 +0200, "VK" <schools_ring@y ahoo.com>[/color]
                  wrote:
                  <snip>[color=blue][color=green]
                  >>Any name has to start with a letter and consist of any
                  >>combination of letters, numbers and underscores to the
                  >>total length of 255 characters. (Where the "letter" means
                  >>any character from the a-z, A-Z range)[/color]
                  >
                  > Not true, see below.
                  >[/color]
                  <snip>[color=blue]
                  >
                  >The message linked says [] in an input name is invalid, the
                  >replies disprove this.[/color]

                  I don't think that the discussion that you referenced does prove the
                  general suggestion that [ and ] are invalid in HTML 4 name attribute
                  strings is incorrect. If I look at the HTM versions of the DTDs I find
                  that the Name attributes are described as CDATA and the term CDATA is
                  linked to:-

                  <quote cite="http://www.w3.org/TR/html4/types.html#type-cdata">
                  ....
                  For some HTML 4 attributes with CDATA attribute values, the
                  specification imposes further constraints on the set of legal values for
                  the attribute that may not be expressed by the DTD.
                  ....

                  ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
                  followed by any number of letters, digits ([0-9]), hyphens ("-"),
                  underscores ("_"), colons (":"), and periods (".").
                  ....
                  </quote>

                  - which is part of the HTML 4 specification and "imposes further
                  constraints" on the contents of name attribute strings beyond the normal
                  definition of CDATA.
                  [color=blue]
                  >Individual languages may have trouble with non-alphabetic
                  >characters as part of a name attribute, but it's valid HTML
                  >and so should really be possible to deal with it in any
                  >language working with HTML.[/color]

                  Valid HTML or not, JavaScript can access properties with names that do
                  not represent valid identifiers in JavaScript by using square bracket
                  notation instead of dot notation:-

                  <URL: http://jibbering.com/faq/#FAQ4_25 >
                  -and-
                  <URL: http://jibbering.com/faq/#FAQ4_39 >

                  Richard.


                  Comment

                  • Andy Hassall

                    #10
                    Re: Radio buttons do not appear checked

                    On Wed, 1 Oct 2003 01:35:37 +0100, "Richard Cornford"
                    <Richard@litote s.demon.co.uk> wrote:
                    [color=blue]
                    >"Andy Hassall" <andy@andyh.co. uk> wrote in message
                    >news:n63knvgnp 4eb5kpvpv09qjvt nca5r37a3n@4ax. com...[color=green]
                    >> On Wed, 1 Oct 2003 01:02:33 +0200, "VK" <schools_ring@y ahoo.com>[/color]
                    >wrote:
                    ><snip>[color=green][color=darkred]
                    >>>Any name has to start with a letter and consist of any
                    >>>combinatio n of letters, numbers and underscores to the
                    >>>total length of 255 characters. (Where the "letter" means
                    >>>any character from the a-z, A-Z range)[/color]
                    >>
                    >> Not true, see below.
                    >>[/color]
                    ><snip>[color=green]
                    >>
                    >>The message linked says [] in an input name is invalid, the
                    >>replies disprove this.[/color]
                    >
                    >I don't think that the discussion that you referenced does prove the
                    >general suggestion that [ and ] are invalid in HTML 4 name attribute
                    >strings is incorrect. If I look at the HTM versions of the DTDs I find
                    >that the Name attributes are described as CDATA and the term CDATA is
                    >linked to:-
                    >
                    ><quote cite="http://www.w3.org/TR/html4/types.html#type-cdata">
                    >...
                    >For some HTML 4 attributes with CDATA attribute values, the
                    >specificatio n imposes further constraints on the set of legal values for
                    >the attribute that may not be expressed by the DTD.
                    >...
                    >
                    >ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
                    >followed by any number of letters, digits ([0-9]), hyphens ("-"),
                    >underscores ("_"), colons (":"), and periods (".").[/color]

                    The name attribute of input is not one of the ID or NAME types, so that
                    restriction doesn't apply.

                    There are attributes that are declared as ID or NAME; input's name attribute
                    is not one of them.
                    [color=blue]
                    >...
                    ></quote>
                    >
                    >- which is part of the HTML 4 specification and "imposes further
                    >constraints" on the contents of name attribute strings beyond the normal
                    >definition of CDATA.[/color]

                    No, the restriction on the NAME and ID types don't apply to the CDATA type.

                    Quoting the whole lot:

                    "
                    * CDATA is a sequence of characters from the document character set and may
                    include character entities. User agents should interpret attribute values as
                    follows:
                    Replace character entities with characters,
                    Ignore line feeds,
                    Replace each carriage return or tab with a single space.
                    User agents may ignore leading and trailing white space in CDATA attribute
                    values (e.g., " myval " may be interpreted as "myval"). Authors should not
                    declare attribute values with leading or trailing white space.

                    For some HTML 4 attributes with CDATA attribute values, the specification
                    imposes further constraints on the set of legal values for the attribute that
                    may not be expressed by the DTD.

                    Although the STYLE and SCRIPT elements use CDATA for their data model, for
                    these elements, CDATA must be handled differently by user agents. Markup and
                    entities must be treated as raw text and passed to the application as is. The
                    first occurrence of the character sequence "</" (end-tag open delimiter) is
                    treated as terminating the end of the element's content. In valid documents,
                    this would be the end tag for the element.

                    * ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by
                    any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons
                    (":"), and periods (".").

                    * IDREF and IDREFS are references to ID tokens defined by other attributes.
                    IDREF is a single token and IDREFS is a space-separated list of tokens.

                    * NUMBER tokens must contain at least one digit ([0-9]).
                    "

                    So, it's saying that if you look through the specification on some of the
                    attributes that are of CDATA type, there are then further notes on restrictions
                    not expressed by it being of type CDATA.

                    There are no further restrictions listed for input's name attribute that I can
                    find - if you can see one please post it!

                    There then follows descriptions of the ID, NAME, IDREF, IDREFS and NUMBER
                    types; none of which are CDATA, they're separate types.

                    For example:



                    The name attribute of the <a> tag is of type CDATA, but it says here that it
                    is restricted to the namespace of the id attribute, which is of type 'name'.

                    That's a "further constraint on the set of legal values for the attribute that
                    may not be expressed by the DTD"
                    [color=blue][color=green]
                    >>Individual languages may have trouble with non-alphabetic
                    >>characters as part of a name attribute, but it's valid HTML
                    >>and so should really be possible to deal with it in any
                    >>language working with HTML.[/color]
                    >
                    >Valid HTML or not, JavaScript can access properties with names that do
                    >not represent valid identifiers in JavaScript by using square bracket
                    >notation instead of dot notation:-
                    >
                    ><URL: http://jibbering.com/faq/#FAQ4_25 >
                    >-and-
                    ><URL: http://jibbering.com/faq/#FAQ4_39 >[/color]

                    Sounds good.

                    --
                    Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
                    Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

                    Comment

                    • Richard Cornford

                      #11
                      Re: Radio buttons do not appear checked

                      "Andy Hassall" <andy@andyh.co. uk> wrote in message
                      news:od8knv0lf4 8rr0l2ckhjb8ish 4m3p4o9ll@4ax.c om...
                      <snip>[color=blue]
                      >No, the restriction on the NAME and ID types don't apply to
                      >the CDATA type.[/color]
                      <snip>

                      Looking at it again I think you are right. Looking at the HTML source of
                      types.html made it clear that CDATA (and notes related to it) is/are
                      separate from NAME and ID (separate LI elements) and the additional
                      restrictions on NAME and ID do not apply. Interesting to see semantic
                      mark-up actually providing additional clarity.

                      Richard.


                      Comment

                      • Geoff Berrow

                        #12
                        Re: Radio buttons do not appear checked

                        I noticed that Message-ID: <od8knv0lf48rr0 l2ckhjb8ish4m3p 4o9ll@4ax.com>
                        from Andy Hassall contained the following:
                        [color=blue][color=green]
                        >>ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
                        >>followed by any number of letters, digits ([0-9]), hyphens ("-"),
                        >>underscores ("_"), colons (":"), and periods (".").[/color]
                        >
                        > The name attribute of input is not one of the ID or NAME types, so that
                        >restriction doesn't apply.
                        >
                        > There are attributes that are declared as ID or NAME; input's name attribute
                        >is not one of them.[/color]

                        You lost me with most of this, but I thought I'd show you the little
                        problem I had today

                        This doesn't work

                        <SCRIPT LANGUAGE="JavaS cript" type="text/javascript">
                        function checkOne(j) {
                        box = eval("document. form1." + j);
                        if (box.checked == false) box.checked = true;
                        }
                        </SCRIPT>

                        <td><select name=\"select". $i."\" onChange=\"chec kOne(".$i.")\">

                        (where $i is a number)

                        But this does:

                        <SCRIPT LANGUAGE="JavaS cript" type="text/javascript">
                        function checkOne(j) {
                        box = eval("document. form1.C" + j);
                        if (box.checked == false) box.checked = true;
                        }
                        </SCRIPT>

                        where I preface the checkbox name with a C

                        --
                        Geoff Berrow
                        It's only Usenet, no one dies.
                        My opinions, not the committee's, mine.
                        Simple RFDs http://www.ckdog.co.uk/rfdmaker/

                        Comment

                        • Lasse Reichstein Nielsen

                          #13
                          Re: Radio buttons do not appear checked

                          Andy Hassall <andy@andyh.co. uk> writes:
                          [color=blue]
                          > The name attribute of input is not one of the ID or NAME types, so that
                          > restriction doesn't apply.
                          >
                          > There are attributes that are declared as ID or NAME; input's name attribute
                          > is not one of them.[/color]

                          You seem to be correct.

                          Checking the DTD of HTML 4.01, only the id attribute is ID, and only
                          two attributes of the meta tag and the type %Lanuagecode are NAME.

                          The only thing that bothers me a bit is this:
                          <URL:http://www.w3.org/TR/html4/struct/global.html#ade f-id>
                          where the id attribute is declared as a (lowercase) "name", which linkes
                          to <URL:http://www.w3.org/TR/html4/types.html#type-name> (the paragraph on
                          ID and NAME tokens). According to the DTD, the id should be an ID.


                          Hmm, I also stubmled over this paragraph:

                          --- <URL:http://www.w3.org/TR/html4/struct/links.html#anch ors-with-id> ---
                          The id and name attributes share the same name space. This means that
                          they cannot both define an anchor with the same name in the same
                          document. It is permissible to use both attributes to specify an
                          element's unique identifier for the following elements: A, APPLET,
                          FORM, FRAME, IFRAME, IMG, and MAP. When both attributes are used on a
                          single element, their values must be identical.
                          ---

                          I can't read with absolute certainty whether this restriction is only
                          on the mentioned elements, and id and name can be distinct on other
                          elements, but I believe it is only for those mentioned. These elements
                          are the ones that are represented in Javascript in global collections,
                          (document.{link s,anchors,apple ts,forms,images }, and window.frames),
                          so they should be globally unique. Comments?
                          [color=blue]
                          > http://www.w3.org/TR/html4/struct/li...ml#adef-name-A
                          >
                          > The name attribute of the <a> tag is of type CDATA, but it says here that it
                          > is restricted to the namespace of the id attribute, which is of type 'name'.[/color]

                          I don't read it as saying the CDATA is *restricted* to the name space
                          of the id attribute. It says
                          "Note that this attribute shares the same name space as the id attribute."
                          Sharing a name space just means that an id attribute and a name attribute
                          with the same value will conflict, and it isn't allowed.

                          I can't see anything that prevents the name attribute from containing
                          characters not possible in an id attribute In fact, in the same
                          section as the above quote, they explicitly mentions "D&uuml;rst " as a
                          legal name attribute value for an anchor.


                          Thanks for pointing this out. I always like to get smarter :)
                          /L
                          --
                          Lasse Reichstein Nielsen - lrn@hotpop.com
                          Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit. html>
                          'Faith without judgement merely degrades the spirit divine.'

                          Comment

                          • De.Snor

                            #14
                            Re: Radio buttons do not appear checked

                            On 30 Sep 2003 13:41:13 -0700, soazine@erols.c om (Phil Powell) wrote:
                            [color=blue]
                            ><b>Agency 4</b>
                            > <input type="radio" name="permissio n[4]" value="1" checked> Yes
                            > <input type="radio" name="permissio n[4]" value="0" > No
                            > <br>
                            > <b>Agency 5</b>
                            > <input type="radio" name="permissio n[5]" value="1" checked> Yes
                            > <input type="radio" name="permissio n[5]" value="0" > No
                            > <br>
                            >
                            >
                            >I have it set up this way but upon viewing in the browser none of the
                            >radio buttons appear checked.
                            >
                            >By the way the radio button names MUST remain in the PHP array format
                            >as they will be referenced EXACTLY like that by PHP on the server end.
                            > Sorry can't change that.
                            >
                            >What can I do?
                            >[/color]
                            If jou'r using XHTML1 jou have to change
                            checked
                            into
                            checked="checke d"

                            --
                            Greetz,
                            De Snor

                            Comment

                            • Dr John Stockton

                              #15
                              Re: Radio buttons do not appear checked

                              JRS: In article <aaeknv8culfi1k mpihjanobsaco1r 2jds1@4ax.com>, seen in
                              news:comp.lang. javascript, Geoff Berrow <bl@ckdog.co.uk .the.cat> posted
                              at Wed, 1 Oct 2003 03:24:10 :-[color=blue]
                              >
                              >if (box.checked == false) box.checked = true;[/color]

                              Unless you feel that false might have been redefined, there is no need
                              to compare with false; there is a NOT operator.

                              if (!box.checked) box.checked = true;

                              There may be no need to test that it is not checked before checking it.

                              --
                              © John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
                              <URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang. javascript
                              <URL:http://www.merlyn.demo n.co.uk/js-index.htm> JS maths, dates, sources.
                              <URL:http://www.merlyn.demo n.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.

                              Comment

                              Working...