| 12
 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
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 
 | function getXMLHttpRequest() {
	var xmlhttp = null;
 
	if (window.XMLHttpRequest || window.ActiveXObject) {
		if (window.ActiveXObject) {
			try {
				alert("1");
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch(e) {
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				alert("2");
			}
		} else {
			xmlhttp = new XMLHttpRequest();
			alert("3");
		}
	} else {
		alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
		return null;
	}
 
	return xmlhttp;
}
 
function request(callback) {
	var xhr = getXMLHttpRequest();
 
	xhr.onreadystatechange = function() {
		if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
			callback(xhr.responseXML);
		}
	};
 
	xhr.open("POST", "fichier/CodePostal.xml",true);
	xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xhr.send(null);
}
 
 
function loadXMLDoc(odata){
	var txt = "";
    x = odata.getElementsByTagName("CP");
 
	y = odata.getElementsByTagName("ville");
 
    for (i=0;i<x.length;i++){
		if (x[i].childNodes[0].nodeValue == document.getElementById("CP1").value){
			txt= y[i].childNodes[0].nodeValue;
		}
    }
    document.getElementById("ville1").value = txt;
} | 
Partager