Re: Input element duplicate names?

Discussion in 'HTML' started by Jukka K. Korpela, Feb 28, 2009.

  1. Ed Jay wrote:

    > Bad or OK...more than one input element with same name,
    > but in different forms?


    Each form has its own set of fields ("controls"), so you can use the same
    name in different forms.

    A page may contain any number of forms, but at least a well-designed page
    normally has at most one.

    > Example:
    >
    > <form name = "form1"....>
    > <input name = "joe"...>
    > </form>
    >
    > <form name = "form2"....>
    > <input name = "joe"...>
    > </form>


    That's not valid in HTML 4.01, which does not allow a name="..." attribute
    for a form. (Use id="..." instead and modify your Javascript code
    accordingly.) But this is a different issue.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Feb 28, 2009
    #1
    1. Advertising

  2. Jukka K. Korpela

    Eric Bednarz Guest

    "Jukka K. Korpela" <> writes:

    >> <form name = "form1"....>


    […]

    > That's not valid in HTML 4.01, which does not allow a name="..."
    > attribute for a form.


    I think you are confusing that with HTML 4.0, or maybe XHTML 1.0.

    > (Use id="..." instead and modify your Javascript
    > code accordingly.)


    What script? I didn’t see any. Anyway, name or id shouldn’t really
    matter since you can use both to identify the form element node in the
    document.forms collection.
    Eric Bednarz, Feb 28, 2009
    #2
    1. Advertising

  3. Eric Bednarz wrote:

    > "Jukka K. Korpela" <> writes:
    >
    >>> <form name = "form1"....>

    >
    > […]
    >
    >> That's not valid in HTML 4.01, which does not allow a name="..."
    >> attribute for a form.

    >
    > I think you are confusing that with HTML 4.0, or maybe XHTML 1.0.


    Indeed I was confusing HTML 4.01 with HTML 4.0 here. Yet, the name="..."
    attribute is illogical for a <form> element, since this is not about naming
    but identification. And the HTML 4.01 spec says:
    "Note. This attribute has been included for backwards compatibility.
    Applications should use the id attribute to identify elements."
    (This applies to name="..." for <form>. Many people have misinterpreted that
    it also applies to form fields, but in them, the attribute has a different
    meaning and there it is indispensable.)

    >> (Use id="..." instead and modify your Javascript
    >> code accordingly.)

    >
    > What script? I didn’t see any.


    Lost your crystal ball? I think it's easy to see that when people use <form
    name="..." ...>, they do so for scripting. The HTML 4.01 spec says, in the
    summary of attributes; "name of form for scripting".

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Jukka K. Korpela, Mar 1, 2009
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Carl
    Replies:
    0
    Views:
    508
  2. Matt
    Replies:
    2
    Views:
    831
    Ben Edgington
    Oct 12, 2004
  3. Replies:
    2
    Views:
    485
  4. Harlan Messinger

    Re: Input element duplicate names?

    Harlan Messinger, Feb 28, 2009, in forum: HTML
    Replies:
    1
    Views:
    870
    Harlan Messinger
    Feb 28, 2009
  5. Sandman

    input names with '-' in their names.

    Sandman, Sep 3, 2003, in forum: Javascript
    Replies:
    4
    Views:
    92
    Lasse Reichstein Nielsen
    Sep 4, 2003
Loading...

Share This Page