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 45 46 47 48 49
| <head>
<script language="JavaScript">
function calcul() {
var total = 0;
// Permet de ne pas declarer le nombre d'elements du formulaires
var nb;
nb = document.devis.coche.length;
total = parseFloat(document.devis.prix_base.value);
// Evalue toutes les cases cochees
for( i = 0 ; i < nb ; i++ ) {
if (document.devis.coche[i].checked) total = total + parseFloat(document.devis.coche[i].value);
}
// Affiche le total de toutes les cases cochees
document.devis.prix_total.value = total;
}
</script>
</head>
<body>
<form name="devis">
<input type="hidden" name="prix_base" value="0">
TABLE
<?php
$table= "25,35";
$fourni = explode(",", $table);
?>
<input name="coche" type="checkbox" value= "<?php echo $fourni[0];echo ','; echo $fourni[1]?>" onclick="calcul()">
CHAISE
<?php
$chaise= "15,56";
$fourni = explode(",", $chaise);
?>
<input name="coche" type="checkbox" value= "<?php echo $fourni[0];echo ','; echo $fourni[1]?>" onclick="calcul()"> <br/><br/>
<input type="text" name="prix_total" value="0" size="8"> Prix TTC<br/><br/>
<input type="reset" value="Effacer">
</form>
</body> |