473,406 Members | 2,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

getElementsByName Not Working in Internet Explorer

In the below code, Firefox displays 2 on the dialog, but Internet Explorer returns 0. Any ideas why this is not working?

Thanks in Advance,
Kurzweil4

[HTML]<html>
<head>
<script type="text/javascript">
function doIt()
{
var obArr = document.getElementsByName( "p_item" );
alert( obArr.length );
}
</script>
</head>
<body>
<table>
<tr>
<td><div name="p_item">123</div></td>
<td><div name="p_item">456</div></td>
<td><a href="javascript:doIt()">Do It</a></td>
</tr>
</table>
</body>
</html>[/HTML]
Sep 12 '07 #1
5 6359
gits
5,390 Expert Mod 4TB
hi ...

i think that getElementsByName() is working with form-elements in IE ... i think this is because that are the elements that have names as standard-attributes - and it seems to ignore all other nodes ... silly behaviour of IE ... so you may use getElementsByTagName() and ask for the value of the attribute with getAttribute('name') ...

kind regards
Sep 12 '07 #2
pbmods
5,821 Expert 4TB
Heya, Kurzweil. Welcome to TSDN!

Please use CODE tags when posting source code:

[CODE=javascript]
JavaScript code goes here.
[/CODE]
Sep 12 '07 #3
dmjpro
2,476 2GB
hi ...

i think that getElementsByName() is working with form-elements in IE ... i think this is because that are the elements that have names as standard-attributes - and it seems to ignore all other nodes ... silly behaviour of IE ... so you may use getElementsByTagName() and ask for the value of the attribute with getAttribute('name') ...

kind regards
Fantastic Gits.
This answer is really Impressive.

Kind regards,
Dmjpro.
Sep 13 '07 #4
hi ...

i think that getElementsByName() is working with form-elements in IE ... i think this is because that are the elements that have names as standard-attributes - and it seems to ignore all other nodes ... silly behaviour of IE ... so you may use getElementsByTagName() and ask for the value of the attribute with getAttribute('name') ...

kind regards
Thanks for the response and solution!

Kurzweil4
Sep 22 '07 #5
Heya, Kurzweil. Welcome to TSDN!

Please use CODE tags when posting source code:

Expand|Select|Wrap|Line Numbers
  1. JavaScript code goes here.
  2.  
Sorry ..I wil do that next time.

Kurzweil4
Sep 22 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Glenn | last post by:
Dynamic help topic links show properly and search brings up links, but when any link is clicked I receive a "Page Cannot be displayed message in the Explorer window and the title bar of Visual...
13
by: joemac | last post by:
I'm just starting out with javascript and the following is not working as it should. The expected prompt dialog box never appears. <head> <script language="JavaScript"><!-- var name;...
21
by: briggs | last post by:
<html> <head> <script> /* AddChild */ function ac() { var c; var p = document.getElementById("p"); for (var i = 0; i < 5; i++) { c = document.createElement("DIV"); // Create 'div' element.
3
by: VK | last post by:
Internet Explorer 7 beta 2 preview CNET Editor review: <http://reviews.cnet.com/Internet_Explorer_7_for_XP_SP2_Beta_2/4505-3514_7-31454661-2.html?tag=nl.e415> Summary (my personal review...
2
by: tsalm | last post by:
Hi everybody, I need to get a element create dynamically by its name. It's ok for FF, but on IE, getElementsByName return "undefined". I create this code but not sure that it can work on older...
3
by: TS | last post by:
I am using IE 7. I have a website running on my local machine (localhost) and auto complete doesnt work for any of the textboxes, but going to web sites on the internet does support this so i know...
2
Frinavale
by: Frinavale | last post by:
I'm attempting to intercept the click event for RadioButons in an attempt to ask the user for confirmation of their action. I determined that Internet Explorer does not reset the previous...
2
by: scdowney | last post by:
First and foremost, thank you in advance for any attempts to help me out. I am working on a project with work, and it requires I use CSS selectors to locate elements within a webpage. For the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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,...

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.