473,662 Members | 2,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

when use ID and when use NAME in a HTML tag ??

I am confused, when use ID and when use NAME to identify an element in HTML
?

Ton den Hartog

--
Computer museum tonh: http://www.tonh.net - 10.000 visitors !!
GGGallery website generator: http://www.tonh.net/gggallery
Vrij Kunst Centrum : http://www.meesterschap.nu

Jul 20 '05 #1
9 7009


Ton den Hartog wrote:
I am confused, when use ID and when use NAME to identify an element in HTML
?


Well, check the HTML 4 specification
http://www.w3.org/TR/html4/
and if you have further questions ask in a newsgroup about HTML.
The id attribute is defined on (nearly) all elements and needs to be
unique in the whole document while the name attribute is defined for
elements like <input>, <textarea>, <select> where on form submission the
name of the element is paired with its value and sent to the server.
The name attribute is also defined on some elements like <img>, <form>,
<applet> back from pre HTML 4 times and still has some usefulness if you
want to script such elements in older browsers like Netscape 4.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
"Ton den Hartog" <to************ ***********@ton h.net> writes:
I am confused, when use ID and when use NAME to identify an element in HTML
?


According to the HTML 4 specification, "id" is recommended for most
elements where "name" is allowed.

Only on form controls ("input", "select", "button", "textarea", and
possibly "object") and the "param" and "meta" elements are "name"
important. On form controls elements, the "name" attribute value
specifies the "control name". In a "param" element it gives tha name
of the parameter. In a "meta" tag, it gives the "metainformatio n name",
whatever that is. If you have both "name" and "id" on such elements,
the "id" gives the globally unique identifier for the element, while
the "name" has a different meaning.

On all other elements that allow a name attribute ("a", "applet",
"form", "frame", "iframe", "img", and "map"), use "id". If you have
both "id" and "name" attributes on such an element, their values must
be equal. <URL:http://www.w3.org/TR/html4/struct/links.html#h-12.2.3>

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
> I am confused, when use ID and when use NAME to identify an element in HTML
?


name is used to annotate POST data in forms. id is used to identify elements for
scripting and styling. Some browsers used them interchangeably , which is
confusing.

http://www.crockford.com

Jul 20 '05 #4
"Douglas Crockford" <no****@covad.n et> wrote in message
news:b9******** *************** ****@msgid.mega newsservers.com ...
Some browsers used them interchangeably , which is
confusing.


I got bit by this one myself today. See my thread "Image Load in IE vs.
Mozilla".

Is there a good web site that compares these kinds of browser differences?
I'm in the process of moving from doing a lot of backend and database
development in VB/ASP/SQL to doing some front end Javascript programming so
anything along this line would be helpful.

--
Frank Carr
jf****@msn.com
http://www15.brinkster.com/vbnotebook
Jul 20 '05 #5
JRS: In article <3f************ **********@news .xs4all.nl>, seen in
news:comp.lang. javascript, Ton den Hartog <ton.den.hartog .removespam@ton
h.net> posted at Sun, 30 Nov 2003 15:25:31 :-
I am confused, when use ID and when use NAME to identify an element in HTML
?


Since ID is required to be unique within the document, whilst NAME is or
can be limited in scope, then use NAME in preference to ID when you have
the choice.

Until recently, the page on which I am currently working used a
different NAME for every element, and every element was created by a
separate piece of HTML, which was satisfactory.

Now that more of the contents are computed rather than typed in, and the
page source is 20% smaller, it is convenient to use identical NAMEs for
matching items in Form A & Form B; the form NAME distinguishes between
them as necessary.

However, ID has one advantage : an editor can easily check that an ID is
unique within a straightforward page, and an ID can be located, easily
but not efficiently, by a search over all IDs.

--
© 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.
Jul 20 '05 #6
A while ago I printed (yep it still exists) a piece (and its still on my
desk) called:
Incompatibiliti es in IE and Netscape: HTML & Javascript.

Not sure whether its usefull.
Link: http://4guysfromrolla.com/webtech/011200-1.shtml

Cheers
Fermin DCG

Frank Carr wrote:
"Douglas Crockford" <no****@covad.n et> wrote in message
news:b9******** *************** ****@msgid.mega newsservers.com ...

Some browsers used them interchangeably , which is
confusing.

I got bit by this one myself today. See my thread "Image Load in IE vs.
Mozilla".

Is there a good web site that compares these kinds of browser differences?
I'm in the process of moving from doing a lot of backend and database
development in VB/ASP/SQL to doing some front end Javascript programming so
anything along this line would be helpful.


Jul 20 '05 #7
"F. Da Costa" <da*****@xs4all .nl> writes:
Incompatibiliti es in IE and Netscape: HTML & Javascript.

Not sure whether its usefull.
Link: http://4guysfromrolla.com/webtech/011200-1.shtml


It's comparing IE 4 to Netscape 4. I would say it's long past it's
expiration date.

(Please don't top post)
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #8
"Ton den Hartog" <to************ ***********@ton h.net> wrote in message news:<3f******* *************** @news.xs4all.nl >...
I am confused, when use ID and when use NAME to identify an element in HTML
?

Ton den Hartog


It really is simply as that:

WHEN using the DOM-Model... and you want to access several elements
with the same NAME (checkboxes / radio-buttons for example)
you HAVE TO use the name-attribute because there only exists the
"document.getEl ementsByName" function which IS handled STRICT in
NS/Mozilla-based browsers and "loosely" (id-attribute works too) by IE
browsers.

my personal opinion about this is:
W3C caused this confusion by entering a "getElementById " to retrieve
info from a UNIQUE element and to retriev info from MORE elements
sharing the same NAME a "getElemntsByNa me" !!! ...really NOT that
"Standard"-like.

so long...
Jul 20 '05 #9
ID is used in DHTML to hide and place globs of html.

name is part of a name-value pair that gets submitted to a server
when there is a submit.
"Ton den Hartog" <to************ ***********@ton h.net> wrote in message news:<3f******* *************** @news.xs4all.nl >...
I am confused, when use ID and when use NAME to identify an element in HTML
?

Ton den Hartog

Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
18322
by: Halldór Ísak Gylfason | last post by:
In my application I have an iframe that is empty (and not visible) initially, however when a user presses a button a form is programmatically submitted and the target is set to the IFrame. I want to detect when the frame has been loaded with the result of the form submit. Of course I have tried some event handlers like onload, onactivate, onreadystatechange, but they do not work in this example. They only seem to work, when the "SRC"...
3
3972
by: Stevie_mac | last post by:
It might be me but... I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I do geta Page_Load event when an item on the ASPX (inside the iFrame) is clicked but then IsPostBack=False by now!. The ASPX is opened via client side script (into an iFrame) inside a .HTM file (as ASPX postback causes problems in a modal internet explorer dialog if not in an iFrame!) Anyone know how to get around this - i need to...
4
4213
by: Zuel | last post by:
Hi Folks. So I have a small problem. My DoPostBack function is not writen to the HTML page nor are the asp:buttons calling the DoPostBack. My Goal is to create a totaly dynamic web page where the server generates the HTML based on a passed in parameter. In our case, CustomerID. Every Customer ges a branded website with there logos and webpage etc.. To Avoid having 1 ASP.Net application running for each client I am attempting a more...
9
4907
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work fine from a link. The button does bring up the popup window, but when I press the links on the page, it doesn't return or close the window. ****************************************************************************
1
4523
by: rbinington | last post by:
Hi, I am trying to write a DNN module that has the ability to insert articles into an article repository. I want the users to be able to move pages around and enter text into the FCKEditor. I want only one instance of the FCKEditor on the screen at one time so I make tabs that the user can click and I store the values in variables behind the scenes. I change the CSS class on the link that is the currently selected one. I have a really...
9
2097
by: GloStix | last post by:
Okay, when I click the link it dissapears and makes a white space underneath it but the space is clickable. so when you click the space, the link actually works Used Firefox 3.0 RC2 for this. OS X 10.5 http://www.screencast.com/t/wgztYUrdN (Video) http://www.jameswmann.com/music.htm (The actual page) HTML
1
2375
by: robin1983 | last post by:
Dear All, I got stuck in simple problem, I have a two php file one for registration form and one for to check and insert into the table. The problem is that when I get any kind error in validiation the code is working properly but when the condition are fulfilled the code inside the if part is not executing. The following is the code for registration form UserAdd.php <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta...
10
6960
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8764
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.