473,545 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need a little help with NODES

Hello,

I am a little confused... please help:

-----------------------------------
<DIV id="01">
<DIV id="aNum"></DIV>
<DIV id="bNum"></DIV>
<DIV id="cNum"></DIV>
</DIV>
------------------------------------

is <DIV id="01"> the parent node of <DIV id="aNum"></DIV> ?

If so... How do I access each child using DOM...

shoud this work?:
a = document.getEle mentById('DIV') ;
b = a(0).childNodes .length;

Thanks...
Jul 23 '05 #1
2 1895
On 8 Sep 2004 15:46:00 -0700, Charlie T <ch************ *@gmail.com> wrote:
Hello,

I am a little confused... please help:

-----------------------------------
<DIV id="01">
<DIV id="aNum"></DIV>
<DIV id="bNum"></DIV>
<DIV id="cNum"></DIV>
</DIV>
------------------------------------

is <DIV id="01"> the parent node of <DIV id="aNum"></DIV> ?
It is the parent of all of the <x>Num DIV elements. However, you should be
aware that you cannot start an id attribute value with a number. It must
begin with a letter.
If so... How do I access each child using DOM...

shoud this work?:
a = document.getEle mentById('DIV') ;
b = a(0).childNodes .length;


No. You'll either want

var a = document.getEle mentById('divId ');

or

var a = document.getEle mentsByTagName( 'DIV');

The first returns a reference to a specific DIV. The second returns a
(possibly empty) collection of all DIV elements in the document. Once you
have a reference to a particular node, then yes, you can use the
childNodes property to access the children of that node.

Another thing to note is that you don't index collections with parentheses
(). You use square brackets []. Whilst IE supports the use of parentheses,
that vast majority of browsers do not (and *should* not).

Finally, all of this has an important caveat: not all browsers you can
encounter on the Web will support the DOM. To be safe, you should always
test for a feature before using it.

if(document.get ElementById)
var d = document.getEle mentById('myDiv ');

if(d && d.childNodes) {
// Do stuff with the childNodes collection
}
}

If you haven't already, do read the FAQ entry on feature detection
(section 4.26):

Good luck,
Mike
clj FAQ:
<URL:http://jibbering.com/faq/>

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

Hello,

I am a little confused... please help:

-----------------------------------
<DIV id="01">
<DIV id="aNum"></DIV>
<DIV id="bNum"></DIV>
<DIV id="cNum"></DIV>
</DIV>
------------------------------------

is <DIV id="01"> the parent node of <DIV id="aNum"></DIV> ?
Yes.

If so... How do I access each child using DOM...

shoud this work?:
a = document.getEle mentById('DIV') ;
b = a(0).childNodes .length;


No, it shouldn't.
"DIV" is not the ID of any of your elements.
"a" is not a function, so "a(0)" is undefined.

a = document.getEle mentById('01');
b = a.childNodes.le ngth;

Note that element '01' in your example has 7 childNodes,
including the text nodes surrounding the <div> nodes.

Jul 23 '05 #3

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

Similar topics

0
4343
by: Mark Rezansoff | last post by:
I have two examples of populating a treeview with AD information below. example A does exactly what I want, starts at the AD tree, but is really slow to generate. examble B gives more information, but is really fast. example B displays all the providers (ie. WinNT, NWcompat, NDS, IIS, and LDAP) I just want it to start at the top level of my...
1
1887
by: mark.engelberg | last post by:
I am having trouble identifying the source of a memory leak in a Windows Python program. The basic gist is as follows: 1. Generate a directed graph (approx. 1000 nodes). 2. Write the graph to a file. 3. Use the os.system command to invoke another program which processes the graph file (graphViz), and generates a gif image of the graph. 4....
0
1637
by: aredo3604gif | last post by:
I have coded a serie of singly linked lists in ANSI C which I have to use. The lists are then stored in a serie of buckets with chained hash table technique. In the various lists there are nodes that carry the same type of data in some of their node fields and some don't. In the various nodes , the struct datatype, there is a flag set to 1...
5
2145
by: Chua Wen Ching | last post by:
Hi, I read from this tutorial at codeproject Question A: http://www.codeproject.com/csharp/GsXPathTutorial.asp regarding xpath.. but i try to apply in my situation, and can't get it work...
7
1736
by: Enigma Curry | last post by:
I need to store a large number of files in an archive. From Python, I need to be able to create an archive, put files into it, modify files that are already in it, and delete files already in it. The easy solution would be to use a zip file or a tar file. Python has good standard modules for accessing those types. However, I would tend to...
0
2599
by: rokuingh | last post by:
ok, so i've been working on this one for quite a while, and the code is very big so i'm just going to give the relevant parts. this is a program that builds polymers (chemical structures of repeated monomers) which are represented as doubly pointed noncomplete binary trees. There are three different types of monomers (hence the three different...
7
9674
by: tman | last post by:
I am generating a very large tree list in my program and while it's performance is great once loaded it takes a really long time to load. I create a root TreeNode "offline" and go through the process of creating building up the tree from there. Only when I am done do I go over to the actual TreeView object on my form and add the my root to...
1
4663
by: satan | last post by:
I need to write the definition of the method leavesCount that takes as a parameter a reference of the root node of a binary tree and returns the numbers of leaves in the binary tree. This what i get so far public class BinaryTree { //Definition of the node protected class BinaryTreeNode { DataElement info;
1
1608
Sl1ver
by: Sl1ver | last post by:
I've implemented search for my nodes if found it will highlight the node yellow but the nodes is programed to show information about it after its selected how will i achieve the information to be shown after the node was found? The program doesn't see the highlighted one as selected This is my code: private void ClearRecursive(TreeNode...
0
7475
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...
0
7921
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...
1
7437
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
5982
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...
0
4958
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...
0
3465
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
3446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1900
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
1023
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.