472,129 Members | 1,696 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,129 software developers and data experts.

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 1732
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.

Similar topics

reply views Thread by Diane Blevins | last post: by
reply views Thread by flashdofu | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.