linea26
-
Modifié par linea26 le 9/11/2011 à 10:55
linea26 -
9 nov. 2011 à 10:56
Bonjour, à tous je cherche mettre en place une devis en ligne avec des listes déroulantes liéés.
Je m'explique, quand l'utilisateur fait un choix dans la première liste cela déclenche l'ouverture d'autre liste. Et ça devra déclanché l'addition de chaque choix.
Maintenant de voudrais mettre un prix pour chaque choix. Mais je ne sais pas ou les mettre et quel fonction appeler pour faire mon calcul.
Voici mon code actuelle avec les listes.
<html>
<head>
<script type="text/javascript" language="javascript">
var format = new Array; //nouveau tableau
format[0] = new Array("p0","A6");
format[1] = new Array("p1", "11x17");
format[2] = new Array("p2", "14x21");
var papier=new Array;
// A6
papier["p0"] = new Array;
papier["p0"][0] = new Array("p0v0", "A6-bouffant");
papier["p0"][1] = new Array("p0v1", "A6-offset");
//11x17
papier["p1"]=new Array;
papier["p1"][0] = new Array("p1v0", "11x17-bouffant");
papier["p1"][1] = new Array("p1v1", "11x17-offet");
//14x21
papier["p2"] = new Array;
papier["p2"][0] = new Array("p2v0", "14x21-bouffant");
papier["p2"][1] = new Array("p2v1", "14x21-offset");
var pagesnb = new Array;
//A6-bouffant
pagesnb["p0v0"] = new Array;
pagesnb["p0v0"][0] = new Array("p0v0r0", "A6-bouffant-de 50 a 100 pages");
pagesnb["p0v0"][1] = new Array("p0v0r1", "A6-bouffant-de 101 a 150 pages");
pagesnb["p0v0"][2] = new Array("p0v0r2", "A6-bouffant-de 151 a 200 pages");
//A6-offset
pagesnb["p0v1"] = new Array;
pagesnb["p0v1"][0] = new Array("p0v1r0", "A6-offset-de 50 a 100 pages");
pagesnb["p0v1"][1] = new Array("p0v1r1", "A6-offset-de 101 a 150 pages");
pagesnb["p0v1"][2] = new Array("p0v1r2", "A6-offset-de 151 a 200 pages");
//11x17-bouffant
pagesnb["p1v0"] = new Array;
pagesnb["p1v0"][0] = new Array("p1v0r0", "11x17-bouffant-de 50 a 100 pages");
pagesnb["p1v0"][1] = new Array("p1v0r1", "11x17-bouffant-de 101 a 150 pages");
pagesnb["p1v0"][2] = new Array("p1v0r2", "11x17-bouffant-de 151 a 200 pages");
//11x17-offset
pagesnb["p1v1"] = new Array;
pagesnb["p1v1"][0] = new Array("p1v1r0", "11x17-offset-de 50 a 100 pages");
pagesnb["p1v1"][1] = new Array("p1v1r1", "11x17-offset-de 101 a 150 pages");
pagesnb["p1v1"][2] = new Array("p1v1r2", "11x17-offset-de 151 a 200 pages");
//14x21-bouffant
pagesnb["p2v0"] = new Array;
pagesnb["p2v0"][0] = new Array("p2v0r0", "14x21-bouffant-de 50 a 100 pages");
pagesnb["p2v0"][1] = new Array("p2v0r1", "14x21-bouffant-de 101 a 150 pages");
pagesnb["p2v0"][2] = new Array("p2v0r2", "14x21-bouffant-de 151 a 200 pages");
//14x21-offset
pagesnb["p2v1"] = new Array;
pagesnb["p2v1"][0] = new Array("p2v1r0", "14x21-offset-de 50 a 100 pages");
pagesnb["p2v1"][1] = new Array("p2v1r1", "14x21-offset-de 101 a 150 pages");
pagesnb["p2v1"][2] = new Array("p2v1r2", "14x21-offset-de 151 a 200 pages");
var pagescl = new Array;
//A6-bouffant
pagescl["p0v0"] = new Array;
pagescl["p0v0"][0] = new Array("p0v0r0", "A6-bouffant-de 50 a 100 pages");
pagescl["p0v0"][1] = new Array("p0v0r1", "A6-bouffant-de 101 a 150 pages");
pagescl["p0v0"][2] = new Array("p0v0r2", "A6-bouffant-de 151 a 200 pages");
//A6-offset
pagescl["p0v1"] = new Array;
pagescl["p0v1"][0] = new Array("p0v1r0", "A6-offset-de 50 a 100 pages");
pagescl["p0v1"][1] = new Array("p0v1r1", "A6-offset-de 101 a 150 pages");
pagescl["p0v1"][2] = new Array("p0v1r2", "A6-offset-de 151 a 200 pages");
//11x17-bouffant
pagescl["p1v0"] = new Array;
pagescl["p1v0"][0] = new Array("p1v0r0", "11x17-bouffant-de 50 a 100 pages");
pagescl["p1v0"][1] = new Array("p1v0r1", "11x17-bouffant-de 101 a 150 pages");
pagescl["p1v0"][2] = new Array("p1v0r2", "11x17-bouffant-de 151 a 200 pages");
//11x17-offset
pagescl["p1v1"] = new Array;
pagescl["p1v1"][0] = new Array("p1v1r0", "11x17-offset-de 50 a 100 pages");
pagescl["p1v1"][1] = new Array("p1v1r1", "11x17-offset-de 101 a 150 pages");
pagescl["p1v1"][2] = new Array("p1v1r2", "11x17-offset-de 151 a 200 pages");
//14x21-bouffant
pagescl["p2v0"] = new Array;
pagescl["p2v0"][0] = new Array("p2v0r0", "14x21-bouffant-de 50 a 100 pages");
pagescl["p2v0"][1] = new Array("p2v0r1", "14x21-bouffant-de 101 a 150 pages");
pagescl["p2v0"][2] = new Array("p2v0r2", "14x21-bouffant-de 151 a 200 pages");
//14x21-offset
pagescl["p2v1"] = new Array;
pagescl["p2v1"][0] = new Array("p2v1r0", "14x21-offset-de 50 a 100 pages");
pagescl["p2v1"][1] = new Array("p2v1r1", "14x21-offset-de 101 a 150 pages");
pagescl["p2v1"][2] = new Array("p2v1r2", "14x21-offset-de 151 a 200 pages");
function filltheselect(liste, choix)
{switch (liste)
{
case "listeformat":
raz("listepapier");
raz("listepagesnb");
raz("listepagescl");
for (i=0; i<papier[choix].length; i++)
{
new_option = new Option(papier[choix][i][1],papier[choix][i][0]);
document.formu.elements["listepapier"].
options[document.formu.elements["listepapier"].length]=new_option;
}
for (i=0; i<pagesnb[choix+"v0"].length; i++)
{
new_option = new Option(pagesnb[choix+"v0"][i][1],pagesnb[choix+"v0"][i][0]);
document.formu.elements["listepagesnb"].options[document.formu.
elements["listepagesnb"].length]=new_option;
}
for (i=0; i<pagescl[choix+"v0"].length; i++)
{
new_option = new Option(pagescl[choix+"v0"][i][1],pagescl[choix+"v0"][i][0]);
document.formu.elements["listepagescl"].options[document.formu.
elements["listepagescl"].length]=new_option;
}
break;
case "listepapier":
raz("listepagesnb");
raz("listepagescl");
for (i=0; i<pagesnb[choix].length; i++)
{
new_option = new Option(pagesnb[choix][i][1],pagesnb[choix][i][0]);
document.formu.elements["listepagesnb"].options[document.formu.
elements["listepagesnb"].length]=new_option;
}
for (i=0; i<pagescl[choix].length; i++)
{
new_option = new Option(pagescl[choix][i][1],pagescl[choix][i][0]);
document.formu.elements["listepagescl"].options[document.formu.
elements["listepagescl"].length]=new_option;
}
break;
}
}
function raz(liste)
{l=document.formu.elements[liste].length;
for (i=l; i>=0; i--)
document.formu.elements[liste].options[i]=null;
}
</script>
</head>
<body>
<form name="formu">
Choisir un format
<select name="listeformat" onChange='filltheselect(this.name, this.value)'>
<script language="javascript">
for (i=0; i<format.length; i++)
document.write("<option value=\"" +format[i][0]+ "\">" +format[i][1]);
</script>
</select>
<br>
Choisir un papier
<select name="listepapier" onChange='filltheselect(this.name, this.value)'>
<script language="javascript">
for (i=0; i<papier["p0"].length; i++)
document.write("<option value=\"" +papier["p0"][i][0]+ "\">" +papier["p0"][i][1]);
</script>
</select>
<br>
Choisir le nombre de pages noir et blanc
<select name="listepagesnb">
<script language="javascript">
for (i=0; i<pagesnb["p0v0"].length; i++)
document.write("<option value=\"" +pagesnb["p0v0"][i][0]+ "\">" +pagesnb["p0v0"][i][1]);
</script>
</select>
<br>
Choisir le nombre de pages couleur
<select name="listepagescl">
<script language="javascript">
for (i=0; i<pagescl["p0v0"].length; i++)
document.write("<option value=\"" +pagescl["p0v0"][i][0]+ "\">" +pagescl["p0v0"][i][1]);
</script>
</select>
<br>
</body>
</html>