1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| window.onload = function() { chargerEntree(); changeImage(); };
valueToImage= {
choisir:"../images/vide.jpg",
salade : "../images/salade.jpg",
escargot : "../images/escargot.jpg",
};
function chargerEntree(){
var entree = document.getElementById("entree");
entree.options[0]=new Option("choisir",00);
entree.options[1]=new Option("Salade",5.95);
entree.options[2]=new Option("Escargot",4.95);
//var repas = document.getElementById("repas");
//repas.options[0]=new Option("choisir",00);
//repas.options[1]=new Option("spaghetti",5.95);
//repas.options[2]=new Option("lasagne",4.95);
};
function changeImage(select){
var valeur = select.options[select.selectedIndex].text;
var prix = select.options[select.selectedIndex].value;
document.getElementById("entree_img").src = valueToImage[valeur];
document.getElementById("entree_num").innerHTML = " " + prix;
} |
Partager