Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

nodeValue: Showing null? (EZ)

Status
Not open for further replies.

milton747

Programmer
Joined
Apr 21, 2005
Messages
133
Location
US
Hi folks,

I have a 'very' simple script to retrieve the node values.
nodeName comes back good. But value is null. Trying to
retrieve either New York or Los Angeles from HTML below.

Any suggestions welcome.
Thanks
Milton.


-- script and HTML below ----- IE 6

<HEAD>
<SCRIPT>
function ShowAll()
{
var ALLDOC = document.getElementsByTagName("*");

for(var i=0; i < ALLDOC.length; i++)
{
if(ALLDOC.nodeName != "NOBR") continue;

alert('nodeName = ' + ALLDOC.nodeName); // OK!
alert('nodeValue = ' + ALLDOC.nodeValue); // Null
}
}
</SCRIPT>

</HEAD>
<BODY BGCOLOR="#ffffff" ONLOAD='ShowAll()' >

<DIV

<DIV
ID="I205"
REGION="EAST"
CLASS=C266
>
<NOBR>New York</NOBR>
<BR>
</DIV>

<DIV
ID="I206"
REGION="WEST"
CLASS=C299
>
<NOBR>Los Angeles</NOBR>
<BR>
</DIV>

</DIV>
</BODY>
 
Code:
<HEAD>
<SCRIPT>
function ShowAll()
{
var ALLDOC = document.getElementsByTagName("*");

    for(var i=0; i < ALLDOC.length; i++)
    {
    if(ALLDOC[i].nodeName != "NOBR") continue;

    alert('nodeName  = ' + ALLDOC[i].nodeName);  // OK!
    alert('nodeValue = ' + ALLDOC[i].firstChild.nodeValue); // Null
    }
}
</SCRIPT>

</HEAD>
<BODY BGCOLOR="#ffffff" ONLOAD='ShowAll()' >

<DIV

<DIV ID="I205" REGION="EAST"CLASS=C266>
<NOBR>New York</NOBR>
<BR />
</DIV>

</BODY>

I don't know the answer but my good friend Google does.
 
Thanks j4606.
This was the final piece of a monster JS I've been developing.

Thanks.
Milton.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top