473,770 Members | 6,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

name vs id in getElementById in NS

Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?
Jul 23 '05 #1
11 3994
On Fri, 15 Oct 2004 10:45:44 -0400, nntp <nn**@rogers.co m> wrote:
Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?


No, for two reasons:

1) getElementById only returns references to elements that have a matching
id. Though IE does return matching names, it is broken in this respect[1].
2) The majority of elements do not have name attributes, and those that do
only continue to have them for backward compatibility with old browsers
like NN4. A DIV certainly does not have, nor has it ever had, a name
attribute.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2
Lee
nntp said:

Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?


There is no need for the name attribute for using getElementById
in any browser. All you need is an id.

Form elements should also have a name, if their value is being
submitted.

Jul 23 '05 #3
"nntp" <nn**@rogers.co m> writes:
Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?


What NS (which I assume means Netscape)?
Not that it matters. Netscape 4 has no getElementById and Netscape 6+
is standards compliant and only finds elements by their "id" using
getElementById.

And there was never a name attribute on div elements. :)

/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 23 '05 #4
I saw it somewhere saying if possible we should use both name and id.
I don't remember if it is about getElementById or something like
frams[blahblah], links, images, forms....
It was saying NS could not find it if we only use name...
I really don't recall it. Anyone has a reference about it?

If i use both name and id, will I get some error, then? such as the same obj
is found twice, or name attribut is not supported?...
nntp said:

Should I use both name and id
<div name="abc" id="abc"> for using getElementById in NS?


There is no need for the name attribute for using getElementById
in any browser. All you need is an id.

Form elements should also have a name, if their value is being
submitted.

Jul 23 '05 #5
nntp wrote:
I saw it somewhere saying if possible we should use both name and id.
I don't remember if it is about getElementById or something like
frams[blahblah], links, images, forms....
It was saying NS could not find it if we only use name...
I really don't recall it. Anyone has a reference about it?

If i use both name and id, will I get some error, then? such as the same obj
is found twice, or name attribut is not supported?...


Why not test it? Its easy enough to do. Then, consult the group FAQ, its
in my signature. The rest might dawn on you also.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #6
Lee wrote:
Form elements should also have a name, if their value is being
submitted.


No they shouldn't. Form _controls_ should.

--
David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Jul 23 '05 #7
David Dorward wrote:
Lee wrote:
Form elements should also have a name, if their value is being
submitted.


No they shouldn't. Form _controls_ should.


I'm sure he was referring to the members of the forms.elements[] collection,
which, although somewhat misnamed, are a form's controls.

--
Grant Wagner <gw*****@agrico reunited.com>
comp.lang.javas cript FAQ - http://jibbering.com/faq

Jul 23 '05 #8
Lee
Grant Wagner said:

David Dorward wrote:
Lee wrote:
> Form elements should also have a name, if their value is being
> submitted.


No they shouldn't. Form _controls_ should.


I'm sure he was referring to the members of the forms.elements[] collection,
which, although somewhat misnamed, are a form's controls.


Yes, except that I don't consider them to be misnamed.
They are the elements that comprise the form.

Jul 23 '05 #9
On 15 Oct 2004 14:50:47 -0700, Lee <RE************ **@cox.net> wrote:
Grant Wagner said:
David Dorward wrote:
Lee wrote:

Form elements should also have a name, if their value is being
submitted.

No they shouldn't. Form _controls_ should.


I'm sure he was referring to the members of the forms.elements[]
collection, which, although somewhat misnamed, are a form's controls.


Yes, except that I don't consider them to be misnamed.
They are the elements that comprise the form.


True, but it can become confusing. Does "form elements" refers to a set of
FORMs, or the elements that the form contains? True, context usually helps
determine which, but I think it's a lot simpler to avoid it altogether by
using "form element" to refer to a FORM, and "form controls" to refer to
INPUT, SELECT, and TEXTAREA elements.

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #10

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

Similar topics

4
13638
by: Carl | last post by:
When using 'name' in the form, it works, when using 'id' it doesn't. Any comments about this? By the way, is this a good method or is it better to use 'getElementById'? Carl <body> <form name="myform"> <input type button id="antw1" value="test"> </form>
21
11383
by: TheKeith | last post by:
I heard that the name attribute is deprecated in html 4.01 strict. Is it recommended that you use the ID attribute for images along with the getElementById method instead of the old way? Thanks.
12
2471
by: CJ | last post by:
Why won't this work? I am passing the name of the form (I have two that use this validation script) but I keep getting an error. Error reads: "document.which_form.name is null or not an object" HTML----------- Form is ----> <form action="thanks.php" method="post" name="contact_form" id="contact_form"> Name -------> <input type="text" name="name" id="name" size="25"> Button sends code -----> <input type="button" value="Submit Form"
6
3215
by: Rich Morey | last post by:
Hi, I have a table where I am altering the layout via javascript to create colspans. I want to then delete the "Extra" cells created by the colspans. I have named the cells "r1c1", "r1c2", "r2c1", etc.. document.getElementById('r2c2').colSpan="4" cellRows = document.getElementById('tableChart').rows(1);
6
23871
by: Neil Cherry | last post by:
I'm working on a JavaScript program and I'm running into name=blah and id=blah. Sometimes it's one or the other and other times it both. Does anyone have a good reference that can help me figure this out? The books I have don't seem to really be of any help as they're more towards JavaScript coding that working with the html/javascript. Here are a few examples: <frameset cols="600, *" id="overallFrame"> <frameset id="leftSide"...
1
2536
by: Invisible Man | last post by:
Thanks for help in advance... I'm trying to change the background of: <li class="noflyout" name="leftnav1"><a href="default.asp">Home </a></li> CSS set it to blue - but want to us JS to change it to red if the user lands on the page... I've got the following JS:
20
7000
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt = document.getElementById('hometab'); Has anyone ever seen anything like this before, or am I dreaming?
6
2310
by: Dick Watson | last post by:
I had a page that works when setup like this: === <form name="frmCalc" action=""> <script type="text/javascript"> function btnCalc_onclick(abc) { return "got here with " + abc; }
7
4874
by: moksha | last post by:
Hi, I am new to javascript and i am facing a problem in coding. plz help me out. I am using javascript for dynamically creating a table row which contains text boxes and radio buttons and check box. I am adding two radio buttons once for a row.Now my problem is the radio buttons in all the rows that added dynamically are behaving as same group i.e when i am selecting a radio button in second row,radio button in first row...
0
9592
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9425
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
10058
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
8886
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
7416
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
6678
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
5313
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...
0
5450
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.