function affecterVille(ville){ debugLocal=0; if (debugLocal==1) alert('affecterVille => ' +ville); document.getElementById('listPaysVille').value=document.getElementById('listPaysVille').value+ville; } function validerVilles(){ debugLocal=0; if (debugLocal==1) alert('validerVilles => validerVilles '); document.getElementById('codeOpe').value='upVille2Zone'; document.getElementById('retour').value=1; document.ajouterVille.submit(); } // --------------------- Liste des villes function fetchCommune (cp){ debugLocal=0; var tabVilleListe=new Array; var url='https://apicarto.ign.fr/api/codes-postaux/communes/'+cp; fetch(url,{ method: "GET", headers: { 'Content-Type': 'application/json', 'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8', 'Access-Control-Allow-Origin':'123ventes.com', } // mode: "no-cors" }) .then(rep => { if (rep.ok === true) return rep.json(); // Ici je traite les erreurs HTTP else { alert('Pas de ville avec ce codePostal : '+cp); return Promise.reject(`Erreur HTTP => ${rep.status}`); } } ) .then(data =>{ if (debugLocal==1) console.log(data); if (debugLocal==1) console.log(data.length); var inner ='