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 38 39 40 41 42 43 44
| function genererSelection(param1,parama2,...){
var xmlhttp = null;
try{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
xmlhttp = false;
}
}
if (!xmlhttp && typeof XMLHttpRequest!='undefined'){
xmlhttp = new XMLHttpRequest();
}
xmlhttp.open('GET', './liste.php?param1='+param1+'¶m2='+param2, false);
xmlhttp.setRequestHeader('User-Agent', 'Test generate select');
xmlhttp.setRequestHeader('Accept', 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.7,*/*;q=0.1');
xmlhttp.send(null);
if(xmlhttp.status == 200){
var liste1 = xmlhttp.responseXML.getElementsByTagName('balise1');
var liste2 = xmlhttp.responseXML.getElementsByTagName('balise2');
var liste_select = document.getElementById('select2');
var tmp = document.createElement('option');
while(document.getElementById('select2').options.length > 1){
document.getElementById('select2').removeChild(document.getElementById('select2').options[1]);
}
for(var i = 0, m = liste1.length; i < m; i++){
tmp.setAttribute('value', liste2[i].firstChild.nodeValue);
tmp.appendChild(document.createTextNode(liste1[i].firstChild.nodeValue));
liste_select.appendChild(tmp);
tmp = tmp.cloneNode(false);
}
liste_select.disabled = false;
}
} |
Partager