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
| <script type="text/javascript" src="prototype.js"></script>
<input type="text" id="ID_VILLE" value="" name="nom" />
<SCRIPT TYPE="text/javascript" LANGUAGE="Javascript">
var text=document.getElementById("ID_VILLE");
function reponse (transport){
var docXML=transport.responseXML;
var nbfils = docXML.firstChild.childNodes.length;
var reponse = "";
for ($i=0; $i<nbfils; $i++) {
if ($i != 0) reponse += "\n";
reponse += docXML.firstChild.childNodes[$i].childNodes[0].childNodes[0].nodeValue+'<br>';
}
document.getElementById("codes").innerHTML=reponse;
}
function alors() {
new Ajax.Request('hello.php',{
method:'get',
parameters: {nom : document.getElementById("ID_VILLE").value},
onSuccess: reponse,
onFailure:function (){ alert("le fichier hello.php n'existe pas")}
});
}
text.onkeyup=function(){
if(text.value.length>2){
alors();
}
}
</SCRIPT>
<p>Codes Postaux<p/>
<div id="codes"></div> |