469,352 Members | 1,661 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,352 developers. It's quick & easy.

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

Jul 24 '05 #1
4 1691
Caversham wrote:
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?


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://lachy.id.au/
http://GetFirefox.com/ Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox
Jul 24 '05 #2
Caversham wrote:
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

name is for backward compatibility with legacy browsers, like NN4x.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
Jul 24 '05 #3
On Sat, 25 Jun 2005 03:18:02 +0200, Jonathan N. Little
<lw*****@centralva.net> wrote:
Caversham wrote:
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

name is for backward compatibility with legacy browsers, like NN4x.

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.
Jul 24 '05 #4
Mitja wrote:
On Sat, 25 Jun 2005 03:18:02 +0200, Jonathan N. Little
<lw*****@centralva.net> wrote:
Caversham wrote:
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

name is for backward compatibility with legacy browsers, like NN4x.

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.


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#control-name>

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

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

--
Rob
Jul 24 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

By using this site, you agree to our Privacy Policy and Terms of Use.