This site is mobile accessible. Press the "Tap Here" button to use a different font-size.
Smartphone icons created by Freepik - Flaticon
Click on a CD to display album information.
// create XMLHttpRequest function const xhttp = new XMLHttpRequest(); let cd; xhttp.onload = function() { const xmlDoc = xhttp.responseXML; cd = xmlDoc.getElementsByTagName("CD"); loadCD(); } // define the XMLHttpRequest Object xhttp.open("GET", "cd_catalog.xml"); xhttp.send(); // display the CD list in a table function loadCD() { let table="<tr><th>Artist</th><th>Title</th></tr>"; for (let i = 0; i < cd.length; i++) { table += "<tr onclick='displayCD(" + i + ")'><td>"; table += cd[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue; table += "</td><td>"; table += cd[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue; table += "</td></tr>"; } document.getElementById("demo").innerHTML = table; } // display information for specific CD function displayCD(i) { document.getElementById("showCD").innerHTML = "Artist: " + cd[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue + "<br>Title: " + cd[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue + "<br>Year: " + cd[i].getElementsByTagName("YEAR")[0].childNodes[0].nodeValue; }