xcandiottix Posted June 18, 2010 Share Posted June 18, 2010 I have an XML document as so: <Tab> <Name N="Private Tab"> <Cell> <Application>X01</Application> </Cell> <Cell> <Application>X02</Application> </Cell> <Cell> <Application>X03</Application> </Cell> </Name> </Tab> <Name N="Public Tab"> <Cell> <Application>X01</Application> </Cell> <Cell> <Application>X02</Application> </Cell> <Cell> <Application>X03</Application> </Cell> </Name> </Tab> I have a javascript that creates 2 input buttons for each Name N="" like so: [Private Tab] [Public Tab] Now, when I click on Private Tab I wan to access the Nodes of the Private Tab and extract the data. So far I have had no luck. Any thoughts? document.write("<table border='1'><tr>"); var x=xmlDoc.getElementsByTagName("Tab"); for (i=0;i<x.length;i++){ document.write("<td>"); document.write('<input type="button" onClick="selection(\'') document.write(x[the letter i].getElementsByTagName("Name")[0].getAttribute("N")); document.write('\')" value="'); document.write(x[the letter i].getElementsByTagName("Name")[0].getAttribute("N")); document.write('"/>'); document.write("</td>"); } document.write("</tr></table>"); function selection(selected){ txt2=xmlDoc.getElementsByTagName("Name")[0].getElementsByTagName("Cell")[0].getElementsByTagName("Application")[0].childNodes[0].nodeValue; document.getElementById("select").innerHTML=txt2; //end } document.write("<div id='select'></div>"); This code works and gives a value of X01 if I click either button. If I click on Public Tab it will not switch to X11. Any help is appreciated! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.