addition champ texte et combobox
Bonjour,
Je souhaite additionner un champ de texte et un combobox pour donner un résultat dans un champ texte resultat
vous trouverez ci-dessous le code utilise :
Code:
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
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Document sans titre</title>
<script language="javascript">
function total()
{
var champ1=document.commande.Champ1.value;
var champ2=document.commande.getElementById('Champ2').options[document.commande.getElementById('Champ2').selectedIndex].value;
document.commande.Reste.value = parseFloat(champ1) + parseFloat(champ2);
}
</script>
</head>
<body>
<form id="commande" name="commande" method="post" action="">
<p>
<input name="Champ1" type="text" id="Champ1" value=0 onkeyup="total()" />
</p>
<p>
<select name="Champ2" id="Champ2" onchange="total()">
<option>Select</option>
<option value="4">test4</option>
<option value="20">test</option>
</select>
</p>
<p>
<input name="Reste" type="text" id="Reste" />
</p>
<p> </p>
</form>
</body>
</html> |
Merci par avance