Problème de résultat d'un calcul
Gilledunord
Messages postés
52
Statut
Membre
-
Gilledunord Messages postés 52 Statut Membre -
Gilledunord Messages postés 52 Statut Membre -
Bonjour,
Le formulaire me donne plusieur zéro après la virgule, par exemple en prenant le prix 12,30 sa marche mais si je mets une quantité de 3 j'ai plusieurs zéro après la virgule.
Comment limiter a deux zéro après la virgule ?
Merci pour votre aide
Le formulaire me donne plusieur zéro après la virgule, par exemple en prenant le prix 12,30 sa marche mais si je mets une quantité de 3 j'ai plusieurs zéro après la virgule.
Comment limiter a deux zéro après la virgule ?
<script type="text/javascript"><!--
function calcul(formulaire) // script de calcul
{
var pu = formulaire.prix.value;
var q = formulaire.quantite.value;
var tot=pu*q;
formulaire.total.value = tot ;
calculTotal();
}
function calculTotal(){
total.somme.value = 0;
for(var i=0;i<document.forms.length-1;i++){
total.somme.value = parseFloat(total.somme.value) + parseFloat(document.forms[i].total.value);
}
}
// --></script>
</head>
<body><form name='produit1' >
<select name='prix' onclick='calcul(produit1)'>
<option>Sélection un titre</option>
<option name='1' value='3.50'>Ref : 125 - Bob Marley - Prix 3,50 €</option>
<option name='2' value='12.30'>Ref : 126 - Johnny - Prix 12,30 €</option>
<option name='3' value='25.25'>Ref : 127 - Dalida - Prix 25,25 €</option>
<option name='4' value='6.26'>Ref : 128 - Mohamed - Prix 6,26 €</option>
<option name='5' value='3.50'>Ref : 129 - Sylvie Vartan - Prix 3,50 €</option>
<option name='6' value='12.30'>Ref : 131 - Daniel Guychard - Prix 12,30 €</option>
<option name='7' value='25.25'>Ref : 131 - Michel Berger - Prix 25,25 €</option>
<option name='8' value='6.26'>Ref : 132 - Alain Barière - Prix 6,26 €</option>
</select>
<input type='text' name='quantite' size='1' maxlength='3' value='1' onChange='calcul(produit1)'>
<input type='text' size='5' name='total' value='0'>
</form>
<br>
<form name='produit2' >
<select name='prix' onclick='calcul(produit2)'>
<option>Sélection un titre</option>
<option name='1' value='3.50'>Ref : 125 - Bob Marley - Prix 3,50 €</option>
<option name='2' value='12.30'>Ref : 126 - Johnny - Prix 12,30 €</option>
<option name='3' value='25.25'>Ref : 127 - Dalida - Prix 25,25 €</option>
<option name='4' value='6.26'>Ref : 128 - Mohamed - Prix 6,26 €</option>
<option name='5' value='3.50'>Ref : 129 - Sylvie Vartan - Prix 3,50 €</option>
<option name='6' value='12.30'>Ref : 131 - Daniel Guychard - Prix 12,30 €</option>
<option name='7' value='25.25'>Ref : 131 - Michel Berger - Prix 25,25 €</option>
<option name='8' value='6.26'>Ref : 132 - Alain Barière - Prix 6,26 €</option>
</select>
<input type='text' name='quantite' size='1' maxlength='3' value='1' onChange='calcul(produit2)'>
<input type='text' size='5' name='total' value='0'>
</form>
<br>
<FORM name='total'>
<input name="somme" type="text" value='' size="6" maxlength="5">Euro
</FORM>
</body>
Merci pour votre aide
A voir également:
- Problème de résultat d'un calcul
- Resultat foot - Télécharger - Vie quotidienne
- Calcul km marche à pied gratuit - Télécharger - Sport
- Calcul de moyenne sur excel - Guide
- Calcul charpente bois gratuit - Télécharger - Architecture & Déco
- Lexer resultat - Télécharger - Sport