Created
February 25, 2019 19:28
-
-
Save bogdan-nourescu/b7673535bfca8ffb45ee45057a9f2e97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style> | |
</style> | |
<script> | |
var persoane=[]; | |
function ajax() { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = function() { | |
if (this.readyState == 4 && this.status == 200) { | |
persoane= JSON.parse(this.responseText); | |
console.log(persoane); | |
draw(); | |
} | |
}; | |
xhttp.open("GET", "https://test-d2273.firebaseio.com/.json", true); | |
xhttp.send(); | |
} | |
function draw(){ | |
/* | |
"..."+ variabila +"..." | |
"" | |
'' | |
` | |
...${variabila}... | |
`*/ | |
var str = ``; | |
for(var i=0;i<persoane.length;i++){ | |
str += ` | |
<tr> | |
<td>${i+1}</td> | |
<td>${persoane[i].nume}</td> | |
<td>${persoane[i].prenume}</td> | |
<td>${persoane[i].varsta}</td> | |
</tr> | |
` | |
str += ""+ | |
"<tr>"+ | |
"<td>"+(i+1)+"</td>"+ | |
"<td>"+persoane[i].nume+"</td>"+ | |
"<td>"+persoane[i].prenume+"</td>"+ | |
"<td>"+persoane[i].varsta+"</td>"+ | |
"</tr>" | |
} | |
document.querySelector("table>tbody").innerHTML=str; | |
} | |
</script> | |
</head> | |
<body onload="ajax()"> | |
<table border="1" > | |
<thead> | |
<tr> | |
<th onclick="sorteaza('nume');">Nume</th> | |
<th onclick="sorteaza('prenume');">Prenume</th> | |
<th onclick="sorteaza('varsta');">Varsta</th> | |
</tr> | |
</thead> | |
<tbody></tbody> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment