Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function tableCD(xh){
- x = JSON.parse(xh.responseText);
- var txt,x,xx,i;
- txt = "<table border='1'><tr><th>Title</th><th>Artist</th></tr>";
- for( i=0; i<x.CD.length; i++ ) {
- txt=txt + "<tr>";
- txt=txt + "<td>" + x.CD[i].TITLE + "</td>";
- txt=txt + "<td>" + xx=x.CD[i].ARTIST + "</td>";
- txt=txt + "</tr>";
- }
- txt=txt + "</table>";
- document.getElementById('txtCDInfo').innerHTML = txt;
- }
- function averageCD(xh){
- x = JSON.parse(xh.responseText);
- var txt,x,xx,i;
- xx=0;
- txt = "Total of all prices: ";
- for( i=0; i<x.CD.length; i++ )
- xx+=parseFloat(x.CD[i].PRICE);
- txt += parseInt(xx*100)/100;
- xx = xx/x.CD.length
- txt += ", and the average: " + parseInt(xx*100)/100;
- document.getElementById('txtCDInfo').innerHTML = txt;
- }
- function loadXMLDoc(url, cb) {
- var xmlhttp;
- xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange=function() {
- if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 ) cb(xmlhttp);
- };
- xmlhttp.open("GET",url,true);
- xmlhttp.send();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement