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
|
var docXml;
function loadXML(){
// Routine de vérification si le navigateur gêre la méthode utilisée
if (document.implementation && document.implementation.createDocument) {
// déclaration pour Mozilla et FF
docXml = document.implementation.createDocument('', '', null);
}
else if (window.ActiveXObject){
// déclaration pour IE
docXml = new ActiveXObject("Microsoft.XMLDOM");
}
else{ alert('Votre navigateur ne saurait pas éxécuter ce script.'); }
docXml.load("avantages.xml");
}
window.onload = function(){ loadXML(); createSelectAv();}
function createSelectAv(){
var noeud = docXml.getElementsByTagName('avantage');
for(var i=0;i < noeud.length; i++){
var nom = noeud[i].getElementsByTagName('nom').firstChild.value;
var cout = noeud[i].getElementsByTagName('cout').firstChild.value;
document.getElementById('selectAv').add(nom+' (Cout : '+cout+')', null);
}
document.getElementById('avantages').appendChild(select);
//générer un select contenant les nom des avantages et affichant le coût une fois selectionné
//type <select><option>nom (Cout : X)</option></select>
} |
Partager