473,554 Members | 2,093 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

document.getEle mentsByName problem

<html>
<head>
<script language="vbscr ipt">
sub window_onload
msgbox document.getEle mentsByName("na me1").length
end sub
</script>
</head>
<body>
<div name="name1">te stDiv</div>
<table id="tbl1" name="name1"><t r><td>table1</td></tr></table>
<table id="tbl2"
name="name1"><t body><tr><td>ta ble2</td></tr></tbody></table>
</body>
</html>

Why document.getEle mentsByName("na me1") returns always 0 ? I have 3 elements
with name property="name1 "

Does anybody know the answer?

Is there any other way to join this 3 elements?

I have about 1000 table elements on the page and I don't want to use
function document.getEle mentsByTagName.

Thank you,
Simon
Nov 19 '05 #1
5 3680
Simon,

Could be the elements are not parsed by the browser yet when window's onload
event fires. Just for testing, make an onclick event for any of the elements
and produce the messagebox there.

Eliyahu

"simon" <si*********@st ud-moderna.si> wrote in message
news:eD******** ******@TK2MSFTN GP10.phx.gbl...
<html>
<head>
<script language="vbscr ipt">
sub window_onload
msgbox document.getEle mentsByName("na me1").length
end sub
</script>
</head>
<body>
<div name="name1">te stDiv</div>
<table id="tbl1" name="name1"><t r><td>table1</td></tr></table>
<table id="tbl2"
name="name1"><t body><tr><td>ta ble2</td></tr></tbody></table>
</body>
</html>

Why document.getEle mentsByName("na me1") returns always 0 ? I have 3 elements with name property="name1 "

Does anybody know the answer?

Is there any other way to join this 3 elements?

I have about 1000 table elements on the page and I don't want to use
function document.getEle mentsByTagName.

Thank you,
Simon

Nov 19 '05 #2
Thank you for your answer.

Even if I execute the msgbox with click event, still the same problem

Thanks,
Simon

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:uZ******** ********@TK2MSF TNGP10.phx.gbl. ..
Simon,

Could be the elements are not parsed by the browser yet when window's
onload
event fires. Just for testing, make an onclick event for any of the
elements
and produce the messagebox there.

Eliyahu

"simon" <si*********@st ud-moderna.si> wrote in message
news:eD******** ******@TK2MSFTN GP10.phx.gbl...
<html>
<head>
<script language="vbscr ipt">
sub window_onload
msgbox document.getEle mentsByName("na me1").length
end sub
</script>
</head>
<body>
<div name="name1">te stDiv</div>
<table id="tbl1" name="name1"><t r><td>table1</td></tr></table>
<table id="tbl2"
name="name1"><t body><tr><td>ta ble2</td></tr></tbody></table>
</body>
</html>

Why document.getEle mentsByName("na me1") returns always 0 ? I have 3

elements
with name property="name1 "

Does anybody know the answer?

Is there any other way to join this 3 elements?

I have about 1000 table elements on the page and I don't want to use
function document.getEle mentsByTagName.

Thank you,
Simon


Nov 19 '05 #3
Try around :
http://msdn.microsoft.com/workshop/a...ies/name_2.asp

It looks like the name attribute doesn't exists for the TABLE tag. It would
make here "name" a custom attribute ignored by getElementsByNa me...
Patrice

--

"simon" <si*********@st ud-moderna.si> a écrit dans le message de
news:eD******** ******@TK2MSFTN GP10.phx.gbl...
<html>
<head>
<script language="vbscr ipt">
sub window_onload
msgbox document.getEle mentsByName("na me1").length
end sub
</script>
</head>
<body>
<div name="name1">te stDiv</div>
<table id="tbl1" name="name1"><t r><td>table1</td></tr></table>
<table id="tbl2"
name="name1"><t body><tr><td>ta ble2</td></tr></tbody></table>
</body>
</html>

Why document.getEle mentsByName("na me1") returns always 0 ? I have 3 elements with name property="name1 "

Does anybody know the answer?

Is there any other way to join this 3 elements?

I have about 1000 table elements on the page and I don't want to use
function document.getEle mentsByTagName.

Thank you,
Simon

Nov 19 '05 #4
getElementsByNa me only works for form elements (<input>,<selec t>, and
<textarea>). to access any html element use getElementById

<html>
<head>
<script language="vbscr ipt">
sub window_onload
msgbox document.getEle mentByName("nam e1").innerHTM L
end sub
</script>
</head>
<body>
<div id="name1">test Div</div>
<table id="tbl1" name="name1"><t r><td>table1</td></tr></table>
<table id="tbl2"
name="name1"><t body><tr><td>ta ble2</td></tr></tbody></table>
</body>
</html>

"simon" <si*********@st ud-moderna.si> wrote in message
news:eD******** ******@TK2MSFTN GP10.phx.gbl...
<html>
<head>
<script language="vbscr ipt">
sub window_onload
msgbox document.getEle mentsByName("na me1").length
end sub
</script>
</head>
<body>
<div name="name1">te stDiv</div>
<table id="tbl1" name="name1"><t r><td>table1</td></tr></table>
<table id="tbl2"
name="name1"><t body><tr><td>ta ble2</td></tr></tbody></table>
</body>
</html>

Why document.getEle mentsByName("na me1") returns always 0 ? I have 3
elements with name property="name1 "

Does anybody know the answer?

Is there any other way to join this 3 elements?

I have about 1000 table elements on the page and I don't want to use
function document.getEle mentsByTagName.

Thank you,
Simon

Nov 19 '05 #5
Hi,

thank you for your answers.
Is there some other way to get the array of tables if getElementsByNa me
doesn't work for tables?

regards,
Simon

"Bruce Barker" <br************ ******@safeco.c om> wrote in message
news:eP******** ******@TK2MSFTN GP15.phx.gbl...
getElementsByNa me only works for form elements (<input>,<selec t>, and
<textarea>). to access any html element use getElementById

<html>
<head>
<script language="vbscr ipt">
sub window_onload
msgbox document.getEle mentByName("nam e1").innerHTM L
end sub
</script>
</head>
<body>
<div id="name1">test Div</div>
<table id="tbl1" name="name1"><t r><td>table1</td></tr></table>
<table id="tbl2"
name="name1"><t body><tr><td>ta ble2</td></tr></tbody></table>
</body>
</html>

"simon" <si*********@st ud-moderna.si> wrote in message
news:eD******** ******@TK2MSFTN GP10.phx.gbl...
<html>
<head>
<script language="vbscr ipt">
sub window_onload
msgbox document.getEle mentsByName("na me1").length
end sub
</script>
</head>
<body>
<div name="name1">te stDiv</div>
<table id="tbl1" name="name1"><t r><td>table1</td></tr></table>
<table id="tbl2"
name="name1"><t body><tr><td>ta ble2</td></tr></tbody></table>
</body>
</html>

Why document.getEle mentsByName("na me1") returns always 0 ? I have 3
elements with name property="name1 "

Does anybody know the answer?

Is there any other way to join this 3 elements?

I have about 1000 table elements on the page and I don't want to use
function document.getEle mentsByTagName.

Thank you,
Simon


Nov 19 '05 #6

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

Similar topics

3
2593
by: Pieter Van Waeyenberge | last post by:
Hello, im some image elements using doc.createElement('IMG'); i set the following styles: - for the images container: white-space:normal; - for the images themselves: display: inline; i append the images to the body ... but the imagery dont wrap when the window gets smaller, unless i append a space (createTextNode) after each image
4
2273
by: Tauqir | last post by:
I am trying to do a simple thing: I have these two text fields in an HTML form. I want to assign the concatenated value to a TEXTAREA. Can someone help me with the syntax? <HTML> <SCRIPT LANGUAGE="JavaScript" TYPE="text/javascript"> </SCRIPT> <table ALIGN="center" border="2" width="100%" cellspacing="8" cellpadding="0"> <FORM action=""...
6
12688
by: mitch | last post by:
It seems like if you create an element dynamically with createElement() and then try to get it later with getElementsByName() it's found in Firefox but not in IE. Here's an example program. Is there something wrong with the program, or is there another way to get elements that have been created dynamically? Thanks. <html> <body>
4
7960
by: david.kuczek | last post by:
I got the following error in a javascript I wrote. The script works fine, but why is the error being displayed??? ##### Here comes the little script: function chgMusicLink(userid,userlink,usertype) { var card_music_id = document.getElementsByName(userid).value; ...
4
1949
by: dal.luc | last post by:
Hello, I've a problem : I want to check which element has been checked in a list of radiobuttons. ///////////////////////////////////// function numeroChk(liste) { var elem=document.all(liste) alert(elem.length)
7
374
by: lukaszmn | last post by:
Hi, I cannot figure out why everything from line "var elem = doc.getElementsByName('keywords')" in x.js is not executed. I want to set value of <input name=keywords ...which is in a.html after page is loaded. ------------------ search.html -------------------- <html> <head> <title>Search</title>
3
1283
by: hantechs | last post by:
Hi, all I found I can get the img element named with "image1" in a html by using "document.image1" with javascript. It's very convenient because I don't need to use the long method like getElementByName etc. I wonder if this approach is the part of the DOM? I have checked the DOM specification, but found nothing. Can somebody give me clue?...
11
4189
Dormilich
by: Dormilich | last post by:
I want to add (prototype) a method to the node list returned by document.getElementsByName() (and related, i.e. NodeList resp. HTMLCollection). unfortunately, neither the NodeList nor the HTMLCollection interface seem to be prototypable in Firefox. (NodeList works in Safari & Opera, don't know about IE) has anyone of you an idea how to...
0
7808
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8047
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...
0
6156
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...
1
5441
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...
0
3570
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...
0
3556
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2022
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
1
1141
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
845
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...

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.