info:calculer_la_somme_de_plusieurs_champs_additions_avec_js

Comment avoir un champ somme aditionnant dynamiquement des valeurs cochées avec js

<SCRIPT LANGUAGE="JavaScript1.1">
function calculesomme() {
value = document.forms[0].Inscription.checked;
Inscription0910 = document.forms[0].Inscription0910.checked;
Inscription1010 = document.forms[0].Inscription1010.checked;
Inscription1110 = document.forms[0].Inscription1110.checked;

	if(value){
		somme=220;
	} else {
		somme1=0;
		somme2=0;
		somme3=0;
	if(Inscription0910){
	somme1=80;
	}
	if(Inscription1010){
	somme2=80;
	}
	if(Inscription1110){
	somme3=80;
	}
somme=somme1+somme2+somme3;


}

document.forms[0].prix.value=somme;
}

</SCRIPT>

		<table><tr>
                  <td colspan="2" valign="top" class="bodytext">Je m'inscris:<br /></td>
                </tr>
                <tr>
                  <td width="6%" valign="top"><input name="Inscription" type="checkbox" value="Session" onChange="calculesomme()" /></td>
                  <td width="94%" colspan="3" valign="top">&agrave; la session ( 3 journ&eacute;es)  CHF 220.-</td>
                </tr>
                <tr>
                  <td valign="top"><input name="Inscription0910" type="checkbox" value="9octobre" onChange="calculesomme()" /></td>
                  <td colspan="3" valign="top">&agrave; la journ&eacute;e du 9 octobre &quot;Aspects de l'histoire du toucher&quot; CHF 80.-</td>
                </tr>
                <tr>
                  <td valign="top"><input name="Inscription1010" type="checkbox" value="10octobre" onChange="calculesomme()" /></td>
                  <td colspan="3" valign="top">&agrave; la journ&eacute;e du 10 octobre &quot;Pratiques th&eacute;rapeutiques actuelles du toucher &quot; CHF 80.-</td>
                </tr>


                <tr>
                   <td valign="top"><input name="Inscription1110" type="checkbox" value="11octobre" onChange="calculesomme()" /></td>
                  <td colspan="3" valign="top">&agrave; la matin&eacute;e du 11 octobre &quot;Le toucher dans la pens&eacute;e contemporaine&quot; CHF 80.-</td>
                </tr>
                <tr>
                  <td colspan="4" valign="top">Somme totale due correspondant &agrave; votre choix: CHF 
                    <input type="text" name="prix" size="6" maxlength="6" value="0" /></td>
                </tr>
</table>
  • info/calculer_la_somme_de_plusieurs_champs_additions_avec_js.txt
  • Dernière modification : 2018/07/18 09:45
  • de radeff