Form <inpu> name & id required?

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

    Form <inpu> name & id required?

    I notice that Dreamweaver automatically adds both name and id
    attributes to form input tags. Are both of these required? Is there
    some recommendation both should be used?

    Caversham

  • Lachlan Hunt

    #2
    Re: Form &lt;inpu&gt; name &amp; id required?

    Caversham wrote:[color=blue]
    > I notice that Dreamweaver automatically adds both name and id
    > attributes to form input tags. Are both of these required? Is there
    > some recommendation both should be used?[/color]

    The name attribute is used when submitting the name=value pairs. The id
    attribute is useful for referencing from other places, such as with the
    for attribute in the label element, with scripts by using
    getElementById( ), with stylesheets using the ID selector, etc. Neither
    of them are required.


    --
    Lachlan Hunt

    http://GetFirefox.com/ Rediscover the Web
    http://GetThunderbird.com/ Reclaim your Inbox

    Comment

    • Jonathan N. Little

      #3
      Re: Form &lt;inpu&gt; name &amp; id required?

      Caversham wrote:
      [color=blue]
      > I notice that Dreamweaver automatically adds both name and id
      > attributes to form input tags. Are both of these required? Is there
      > some recommendation both should be used?
      >
      > Caversham
      >[/color]
      name is for backward compatibility with legacy browsers, like NN4x.

      --
      Take care,

      Jonathan
      -------------------
      LITTLE WORKS STUDIO

      Comment

      • Mitja

        #4
        Re: Form &lt;inpu&gt; name &amp; id required?

        On Sat, 25 Jun 2005 03:18:02 +0200, Jonathan N. Little
        <lws4art@centra lva.net> wrote:
        [color=blue]
        > Caversham wrote:
        >[color=green]
        >> I notice that Dreamweaver automatically adds both name and id
        >> attributes to form input tags. Are both of these required? Is there
        >> some recommendation both should be used?
        >> Caversham
        >>[/color]
        > name is for backward compatibility with legacy browsers, like NN4x.
        >[/color]
        Not for form elements. Try
        <form ...>
        <input type="text" id="foo" value="bar"> <input type="submit">
        </form>
        and see if it works :)
        ID and name have different semantics and uses, like Lachlan explained.

        Comment

        • RobG

          #5
          Re: Form &lt;inpu&gt; name &amp; id required?

          Mitja wrote:[color=blue]
          > On Sat, 25 Jun 2005 03:18:02 +0200, Jonathan N. Little
          > <lws4art@centra lva.net> wrote:
          >[color=green]
          >> Caversham wrote:
          >>[color=darkred]
          >>> I notice that Dreamweaver automatically adds both name and id
          >>> attributes to form input tags. Are both of these required? Is there
          >>> some recommendation both should be used?
          >>> Caversham
          >>>[/color]
          >> name is for backward compatibility with legacy browsers, like NN4x.
          >>[/color]
          > Not for form elements. Try
          > <form ...>
          > <input type="text" id="foo" value="bar"> <input type="submit">
          > </form>
          > and see if it works :)
          > ID and name have different semantics and uses, like Lachlan explained.[/color]

          Input & name:
          <URL:http://www.w3.org/TR/html4/interact/forms.html#adef-name-INPUT>
          <URL:http://www.w3.org/TR/html4/interact/forms.html#cont rol-name>

          ID:
          <URL:http://www.w3.org/TR/html4/struct/global.html#ade f-id>

          HTML attributes:
          <URL:http://www.w3.org/TR/html4/index/attributes.html >



          --
          Rob

          Comment

          Working...