Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > =?ISO-8859-1?Q?...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 17 Topic 35532 of 37128
Post > Topic >>

=?ISO-8859-1?Q?Calcul_instantan=E9?=

by DamDamDeo <dam.courriel@[EMAIL PROTECTED] > May 8, 2008 at 12:08 PM

Bonjour =E0 tous,
je permets ce petit message, ceci afin de soliciter votre aide sur un
petit probl=E8me...

Voici mon formulaire (du moins une partie) :

[code]
<body>
<form name=3D"form1" method=3D"post" action=3D""><table width=3D"389"
border=3D"1">
 <table width=3D"46%" border=3D"0" cellspacing=3D"2" cellpadding=3D"0">
                  <tr>
                    <td width=3D"29%">&nbsp;</td>
                    <td width=3D"22%"><div
align=3D"center"><strong>acteur</strong></div></td>
                    <td width=3D"25%"><div
align=3D"center"><strong>chanteur</strong></div></td>
                    <td width=3D"24%">total</td>
    </tr>
                  <tr>
                    <td>Adultes</td>
                    <td>

                          <input name=3D"ch_acteur_adultes" type=3D"text"
id=3D"ch_acteur_adultes" size=3D"10" onchange=3D"add()"/
>                      </td>
                    <td>
                      <input name=3D"chanteur_adulte" type=3D"text"
id=3D"chanteur_adulte" size=3D"10" onchange=3D"add()"/>                   
<=
/
td>
                    <td><input name=3D"total_adultes" type=3D"text"
id=3D"total_adultes" size=3D"10" style=3D"border:solid 2px  #FF6600"
readonly=3D"true"/></td>
                  </tr>
                  <tr>
                    <td>De 12 &agrave; 18 ans</td>
                    <td>
                      <input name=3D"ch_acteur_18" type=3D"text"
id=3D"ch_acteur_18" size=3D"10" onchange=3D"add()"/>                    </
td>
                    <td>
                      <input name=3D"chanteur_18" type=3D"text"
id=3D"chanteur_18" size=3D"10" />                    </td>
                    <td><input name=3D"total_18" type=3D"text"
id=3D"total_18" size=3D"10" style=3D"border:solid 2px  #FF6600"
readonly=3D"true"/></td>
                  </tr>
                  <tr>
                    <td>Moins de 12 ans</td>
                    <td>
                        <input name=3D"ch_acteur_12" type=3D"text"
id=3D"ch_acteur_12" size=3D"10" onchange=3D"add()"/>                    </
td>
                    <td>
                        <input name=3D"chanteur_12" type=3D"text"
id=3D"chanteur_12" size=3D"10" />                   </td>
                    <td>
                      <input name=3D"total_12" type=3D"text"
id=3D"total_12"=

size=3D"10" style=3D"border:solid 2px  #FF6600" readonly=3D"true"/
>                   </td>
                  </tr>
                  <tr>
                    <td>total</td>
                    <td><input name=3D"total_acteur" type=3D"text"
id=3D"total_acteur" size=3D"10" style=3D"border:solid 2px  #FF6600"
readonly=3D"true"/></td>
                    <td><input name=3D"total_chanteur" type=3D"text"
id=3D"total_chanteur" size=3D"10" style=3D"border:solid 2px  #FF6600"
readonly=3D"true"/></td>
                    <td><input name=3D"total" type=3D"text" id=3D"total"
size=3D"10" style=3D"border:solid 2px  #FF6600" readonly=3D"true"/></td>
                  </tr>
                </table>


</form>





</body>
[code]

Le but de ce formulaire est de calculer le nb d'adh=E9rents pour chaque
cat=E9gorie, et pour cela, j'utilise le petit script suivant :

[code]
<script type=3D"text/javascript">
function purge(nbre) {
// conversion s=E9parateur ',' en '.'
nbre =3D nbre.replace(',','.');
// recherche et remplacement de caract=E8res non d=E9sir=E9s
nbre =3D nbre.replace(/([^0-9 ^.]|\.{2,5}|\s)/g,'');
return nbre;
}
function add() {
var f =3D do***ent.forms[0];
var tot =3D 0;
// pour chaque =E9l=E9ment du formulaire
for(var i=3D0; i<f.length; i++) {
// si c'est un champ de texte et dont le nom commence par 'ch_'
if(f[i].type=3D=3D'text' && f[i].name.indexOf('ch_')>=3D0) {
// correction du contenu du champ
f[i].value =3D purge(f[i].value);
// ajout de cette valeur =E0 la variable 'tot'
tot +=3D f[i].value*1;
// comme la valeur d'un champ est de type texte
// on l'a transform=E9e en nombre (en le multipliant par 1)
// avant de faire l'addition
}
}
// insertion du r=E9sultat
f['total_acteur'].value =3D tot;
}
</script>


[/code]

Mon soucis est que ce script ne me permet pas de faire plusieurs
calculs dans un m=EAme formulaire.
Comment rem=E9dier =E0 ce soucis qui commence =E0 me hanter depuis
plusieurs=

jours maintenant.

D'avance merci,
 




 17 Posts in Topic:
=?ISO-8859-1?Q?Calcul_instantan=E9?=
DamDamDeo <dam.courrie  2008-05-08 12:08:04 
Re: Calcul =?ISO-8859-1?Q?instantan=E9?=
sheldonlg <sheldonlg&g  2008-05-08 17:17:35 
=?iso-8859-1?Q?Re:_Calcul_instantan=E9?=
"Richard Cornford&qu  2008-05-08 23:10:18 
Re: Calcul =?ISO-8859-1?Q?instantan=E9?=
sheldonlg <sheldonlg&g  2008-05-09 07:54:44 
Re: Calcul =?ISO-8859-1?Q?instantan=E9?=
berzemus <pmo@[EMAIL P  2008-05-09 10:43:42 
Re: Calcul =?ISO-8859-1?Q?instantan=E9?=
sheldonlg <sheldonlg&g  2008-05-09 07:56:09 
=?ISO-8859-1?Q?Re=3A_Calcul_instantan=E9?=
DamDamDeo <dam.courrie  2008-05-09 02:52:06 
Re: Calcul instantané
Dr J R Stockton <jrs@[  2008-05-09 10:57:11 
Re: Calcul =?ISO-8859-1?Q?instantan=E9?=
sheldonlg <sheldonlg&g  2008-05-09 16:05:54 
Re: Calcul instantané
"Evertjan." <  2008-05-09 20:41:41 
Re: Calcul =?ISO-8859-1?Q?instantan=E9?=
sheldonlg <sheldonlg&g  2008-05-09 17:15:43 
OT: The Netherlands
sheldonlg <sheldonlg&g  2008-05-09 17:23:10 
Re: OT: The Netherlands
"Evertjan." <  2008-05-10 09:29:51 
Re: Calcul =?iso-8859-1?q?instantan=E9?=
Ivan Marsh <ivanmarsh@  2008-05-09 15:46:25 
Re: Calcul =?ISO-8859-1?Q?instantan=E9?=
John W Kennedy <jwkenn  2008-05-09 21:51:53 
=?ISO-8859-1?Q?Re=3A_Calcul_instantan=E9?=
VK <schools_ring@[EMAI  2008-05-09 14:53:43 
Re: Calcul =?utf-8?Q?instantan=C3=A9?=
ad@[EMAIL PROTECTED] (Ar  2008-05-15 11:06:34 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Oct 10 14:53:50 CDT 2008.