1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <html>
<head>
</head>
<body>
<script>
function evaluer()
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {format(xhr.responseText);} // xhr.php renvoie une chaine de type "41;34,65;124" ?
};
xhr.open("GET", "xhr.php", true);
xhr.send(null);
}
function format(chaine)
{
var reg=new RegExp("[ ,;]+", "g");
var tab = chaine.split(reg);
for(var i=0;i<tab.length;i++)
{
document.getElementById("vainqueur"+i).value = tab[i];
}
}
</script>
<form>
<input type="text" id="vainqueur0" />
<input type="text" id="vainqueur1" />
<input type="text" id="vainqueur2" />
<input type="text" id="vainqueur3" />
<br />
<input type="button" value="evaluer" onclick="evaluer()" />
</form>
</body>
</html> |