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.

Help Please - Coding in Javascript

Hi

I'm having trouble with my javascript. I retrieving my data from a XML document:

Expand|Select|Wrap|Line Numbers
  1. <root>
  2.        <item>Happy
  3.                <item filePath="http://www.smile.com">Smile</item>
  4.                <item filePath="http://www.laugh.com">Laugh</item>
  5.                <item filePath="http://www.haha.com">Haha</item>
  6.       </item>
  7.       <item>Sad
  8.               <item filePath="http://www.cry.com">Cry</item>
  9.               <item filePath="http://www.upset.com">Upset</item>
  10.       </item>
  11.       <item>Angry
  12.               <item......>....</item>
  13.       </item>
  14. </root>
  15.  
The following is the code I have so far:

Expand|Select|Wrap|Line Numbers
  1.    function getXMLlinks() 
  2.    { 
  3.       var XMLVal; 
  4.       var itemURL,i; 
  5.       var itemXML; 
  6.       var dropList,nodes; 
  7.       var headNode; 
  8.       var itemNode;         
  9.  
  10.       XMLVal  = new ActiveXObject("Msxml2.XMLHTTP"); 
  11.       itemXML = new ActiveXObject("Microsoft.XMLDOM"); 
  12.       itemURL = 'http://www.emotions.xml'; 
  13.  
  14.       XMLVal.open("POST",itemURL, false,"",""); 
  15.       XMLVal.setRequestHeader("content-type","text/xml"); 
  16.       XMLVal.send(''); 
  17.  
  18.       itemXML.loadXML(XMLVal.responseText); 
  19.  
  20.       var root = itemXML.documentElement; 
  21.       var elem = root.getElementsByTagName("item"); 
  22.       var n = itemXML.documentElement.firstChild; 
  23.  
  24.       var numNodes = elem.length; 
  25.       var writeLinks = ""; 
  26.       for (var i=0; i<numNodes; i++) 
  27.       { 
  28.           var elemvalue = elem.item(i).getAttribute("filePath"); 
  29.           if (elemvalue == "null") 
  30.           { 
  31.              writeLinks = writeLinks + elem.text + '<br/>'; 
  32.           } 
  33.           else 
  34.           { 
  35.              writeLinks = writeLinks + '<a href="' + elemvalue + '">' + elem.item(i).text + '</a><br/>' 
  36.           } 
  37.       } 
  38.       linkList.innerHTML = writeLinks; 
  39.  
  40.    } 
  41.  
What I am trying to do is get the first "item" nodes and display it on a webpage. Then place all the child "item" nodes under the first "item" node. For example, on the webpage: happy, sad and angry will be displayed. But when the user clicks onto "happy" it expands and smile, laugh and haha will be displayed. When the user clicks onto smile it will redirect the user to the "smile" webpage.

Any help will be much appreciated.

Thanks!
Nov 9 '06 #1
1 1156
vssp
268 100+
function countryprocess2()
{

if (http.readyState == 4) {
//alert (http.readyState);
// Split the comma delimited response into an array
if(http.status==200)
{

//alert (http.status);
//alert (http.responseText);
//alert (document.getElementById("Country").value);
document.getElementById("Your_school").length=0;
document.getElementById("Your_school").options[0]=new Option("Select School"," ");

if(http.responseText!="No values")
{

var clist=http.responseText.split("_");
for(i=0;i<clist.length;i++)
{
var myclist=clist[i].split(",");
// alert (myclist);
document.getElementById("Your_school").options[i+1]=new Option(myclist[1],myclist[0]);
}
}
else
{
document.getElementById("Your_school").length=0;
document.getElementById("Your_school").options[0]=new Option("Select School"," ");
}
}

}
}



this code get the xml content to filter the date

vssp
Nov 10 '06 #2

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

Similar topics

11
by: Jack | last post by:
I have a asp form where among others there are few text boxes and one check box. The checkbox is to indicate whether the entry is final. The checkbox is attahced to a field in table of type...
5
by: TrvlOrm | last post by:
Can any one please help me...I am new to JavaScript and I have been struggling with this code for days now and can't figure it out. I would like to get the Buttons to correspond with the action...
7
by: Trvl Orm | last post by:
I am working with 2 frames, Left and Right and the main code is in the left frame, which has been attached. Can someone please help me with this code. I am new to JavaScript and can't figure it...
14
by: TrvlOrm | last post by:
OK. After much playing around, I managed to get my frame page this far.. see code below. BUT...there are still errors with it, and what I would like to have happened is this: 1) On the Left...
8
by: Cyberdog | last post by:
HI, I am learning javascript, and at the moment I am working on truth tables. Can someone please tell me, is "NOT A AND B" the same as "NOT A AND NOT B". Thanks
1
by: Sunshine | last post by:
Pretty new to javascript so please help. Why isn't this working in my validateform()? if (document.This.strOld.value.compareTo(Session("strPassword")) != 0) { alert("Current password...
4
by: Adrienne | last post by:
I am the first to admit that I know bupkis about javascript, except that sometimes I need it to do something client side that I can't do server side. Anyway, here's my problem: <input...
2
by: Daniel | last post by:
I'm new to .Net and all of its abilities so I hope this makes sense. Basically I'm confused on when is the appropriate time to use web forms controls vs. regular HTML. For example in ASP...
4
mikeinspain
by: mikeinspain | last post by:
I am getting a Fatal Error message as shown below; Fatal error: Call to undefined function: phprequire() in /home/9144/domains/cbweb.co.uk/html/propertyEnquiry.php on line 1 The code behind this...
1
by: al2004 | last post by:
Write a program that reads information about youth soccer teams from a file, calculates the average score for each team and prints the averages in a neatly formatted table along with the team name....
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.