html - Call one function from another function in javascript -


I am still a newbie with Web Technologies and I have some questions with the following code.

I am trying to call getDetails () function from any other Javascript function displayTable (). Click on the 'My CD Fact' button, displayTable () is implemented.

Well, this is not working for me. I have some silly estimation of this but I can not understand. I tried to diagnose it with firebug and said that getDetails () is not defined.

In addition, I have an original CSS file to display the table in a particular style. He is not working either, is it because I have added it to the body and I am using it in my head?

  & lt; Script type = "text / javascript" & gt; Var xmlDoc; Function displayTable () {var artist name; If (window.XMLHttpRequest) {xmlDoc = new window.XMLHttpRequest (); XmlDoc.open ("GET", "Artists.xml", false); XmlDoc.send (""); XmlDoc = xmlDoc.responseXML; } And if (ActiveXObject ("Microsoft.XMLDOM")) {xmlDoc = New ActiveXObject ("Microsoft.XMLDOM"); XmlDoc.async = false; XmlDoc.load ("Artists.xml"); } Document.write ("& lt; table class = \" artist worthy \ "limit = '1' & gt;"); Document.write ("<<" & gt; Artist & lt; / th> & lt; th & gt; Title & lt; / th & gt; "); Var x = xmlDoc.getElementsByTagName ("CD"); (I = 0; i & lt; x.length; i ++) {Artist name = x [i] .getElementsByTagName ("ARTIIT") [0]. ChildNode [0] .nodvalue; Document.write ("& lt; & lt; td> & lt; a href = \" JavaScript: getDetails (artistName); \ "& gt;"); Document.write (artistName); Document.write ("& lt; / a & gt; & lt; / td> gt; & lt; / tr & gt;"); } Document.write ("& lt; / table>"); } Function getDetails (artist name) {warning (artist name); } & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Link rel = "stylesheet" type = "text / css" href = "style.css" & gt; & Lt; Form & gt; & Lt; Input type = "button" value = "my CD fact" onclick = "displayTable ()" /> & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

Cheers

getDetails () in a JavaScript buit-function . This is a user-defined function. Those who wrote the book, their first head first Ajax has defined their version of getDetails () on page 24.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -