473,326 Members | 2,813 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,326 software developers and data experts.

Javascript For Loop displays only one of two firstChild.nodeValues in String

I have tried with one for loop or two for loops. I've even separated
each firstChild.nodeValu e by a semicolon and I still get the same
result. It will print with one of the nodeValues, but not both. I
have double checked whether the javascript can acually read either
nodeValues by using alert(nodeValue) checks and it does. But when it comes to displaying it displays one or the other and not both. I've even tried creating a separate array thinking it might be due to an out of memory error. But still
get the same result. Any suggestions are highly appreciated.

This is the for loop

Expand|Select|Wrap|Line Numbers
  1. var str = 'The node list has ' + objNodeList. length + ' items.\n';
  2. for( var i = 0; i < objNodeList. length; i++ ) {
  3. str = str + "<option value=objNodeList2[ i].firstChild. nodeValue> " +
  4. (i + 1) + ': ' + objNodeList[ i].firstChild. nodeValue + "<\/option>" +
  5. '\n';

This is what the page source looks like. Notice it only prints one of
the nodeValues and not both . The nodeValue that won't display is the
URL. Please note, this is completely interchangeable. It will print
one or the other list of nodeValues and not both. And please note I've checked to see if both nodes are readable using alert() checks. And they are, but only one of the list of Nodes displays in the popup webpage. Please help.

[HTML]<SELECT
onchange="window. location. href=this. options[this. selectedIndex] .value">< pre>The
node list has 21 items.
<option value=objNodeList2[ i].firstChild. nodeValue> 1: NYT > Books</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 2: NYT > Books</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 3: Books of The
Times: The Case for Another Drug War, Against Pharmaceutical
Marketers' Dirty Tactics</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 4: Magda Cordell
McHale, 86, Futurist Thinker, Is Dead</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 5: For Youngsters,
Leaps and Boundaries</ option>
<option value=objNodeList2[ i].firstChild. nodeValue> 6: Exhibition
Review: A Giant's Roaring, Faintly Echoed</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 7: Western Authors
Celebrate a Master</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 8: A $100 Million
Donation to the N.Y. Public Library</option>

<option value=objNodeList2[ i].firstChild. nodeValue> 9: Neighborhood
Watch</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 10: What's
Left</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 11: Woe Be
Gone</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 12: Wild and Crazy
Guys</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 13: Obsessed (Agog,
Beset, Consumed, Driven, etc.)</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 14: The Wrong
War</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 15: Hot or Not</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 16: I Feel
Good</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 17: The
Interrogator< /option>

<option value=objNodeList2[ i].firstChild. nodeValue> 18: Children's
Books: Keep On Truckin'</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 19: Archive: Book
Review Podcast</option>
<option value=objNodeList2[ i].firstChild. nodeValue> 20: Essay:
Admission Impossible</ option>
<option value=objNodeList2[ i].firstChild. nodeValue> 21: The Funny Pages
| Sunday Serial: The Lemur</option>
</pre>[/HTML]
Apr 11 '08 #1
1 1932
acoder
16,027 Expert Mod 8TB
Try this:
Expand|Select|Wrap|Line Numbers
  1. var str = 'The node list has ' + objNodeList. length + ' items.\n';
  2. for( var i = 0; i < objNodeList. length; i++ ) {
  3. str = str + "<option value='" + objNodeList2[ i].firstChild.nodeValue + "'> " +
  4. (i + 1) + ': ' + objNodeList[ i].firstChild.nodeValue + "<\/option>" +
  5. '\n';
Apr 12 '08 #2

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

Similar topics

1
by: Leila | last post by:
Hi folks, I have a fairly complex xml document which looks like this: <my:InsideView xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-08-02T14:22:59" xml:lang="en-us">...
0
by: milkyway | last post by:
Hello, Just new to all of this. The code below is supposed to load an XML file for use in a table. It doesn't work because of one command: table.insertRow command: I have seen the specs...
72
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
19
by: Stimp | last post by:
preferably one that when clicked can update three date dropdowns (day, month, year) like http://www.visitdublin.com/carhire/avis.asp Don't mind paying for the file... anyone seen something...
3
by: arun32581 | last post by:
I am developing a page for Mozilla/IE which reads xml data and when the link on the page is clicked it displays the data as a table. The display is controlled by a Javascript. Everything works...
2
by: alxasa | last post by:
Hi, I have a setInterval which executes its command every 10 seconds in a infinite loop. I've got something real basic like: var processes=0; function startme(){ if(stopthisloop>1)
9
by: hendedav | last post by:
Gang, I am trying to get a regular expression test to work and can't figure out why. I will give you the code below: for (var j=0; j<document.getElementById('cmbList').options.length; j+...
7
by: psybert | last post by:
Hello everyone, Long time lurker, first time poster. I'm a beginner coder, and I've taught myself everything with the help and expertise of users and websites like this one. I normally figure out...
2
by: joelkeepup | last post by:
Hi, I made a change this morning and now im getting an error that says either "a is undefined or null" or "e is undefined or null" the microsoft ajax line is below, I have no idea how to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.