469,363 Members | 2,484 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,363 developers. It's quick & easy.

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 1102
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

Post your reply

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

Similar topics

5 posts views Thread by TrvlOrm | last post: by
7 posts views Thread by Trvl Orm | last post: by
8 posts views Thread by Cyberdog | last post: by
1 post views Thread by Sunshine | last post: by
4 posts views Thread by Adrienne | last post: by
2 posts views Thread by Daniel | last post: by
1 post views Thread by al2004 | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.