Forum de discussion
Forum « Programmation Javascript » (archives)
Re: Addition de champs
Envoyé: 22 décembre 2005, 4h23 par dehian
<!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.getElementById('Champ2').options[document.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 value="0">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>
Réponses
|