Bonjour

J'ai un formulaire en html où doit se calculer différentes lignes ; le premier calcul se fait correctement (fonction somme() en javascript)
mais la seconde ligne ne se calcul pas automatique (fonction resultat_cg() )
Pourriez-vous m'aider
merci
Pierre

voici le code :


Code html : Sélectionner tout - Visualiser dans une fenêtre à part
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>calcul_cotisations</title>
</head>
<body>
<form method="post" name="calcul_cotisations">
  <table style="text-align: left; width: 1150px; height: 110px;"
 border="0" cellpadding="2" cellspacing="2">
    <tbody>
      <tr>
        <td
 style="width: 281px; font-family: Arial; font-weight: bold; text-align: center; background-color: rgb(226, 189, 255);"><small>Code
et cat&eacute;gories de salari&eacute;s</small></td>
        <td
 style="width: 228px; font-family: Arial; font-weight: bold; text-align: center; background-color: rgb(226, 189, 255);"><small>Salaires<br>
&nbsp;arrondis</small></td>
        <td
 style="width: 134px; font-family: Arial; font-weight: bold; text-align: center; background-color: rgb(226, 189, 255);"><small>Taux
en %</small></td>
        <td
 style="width: 302px; font-family: Arial; font-weight: bold; text-align: center; background-color: rgb(226, 189, 255);"><small>Cotisations
arrondies </small></td>
      </tr>
      <tr>
        <td style="width: 281px; font-family: Arial;"><small>100
A RG cas g&eacute;n&eacute;ral - accident du travail</small></td>
        <td
 style="text-align: center; width: 228px; font-family: Arial;"><small><input
 id="base_at" onchange="somme();" value="0"
 type="text"></small></td>
        <td
 style="width: 134px; font-family: Arial; text-align: center;"><small><input
 id="at" onchange="somme();" value="2" type="text"></small></td>
        <td
 style="text-align: center; width: 302px; font-family: Arial;"><small><span><input
 id="resultat" value="0" type="text"></span></small></td>
      </tr>
      <tr>
        <td style="width: 281px; font-family: Arial;"><small>100
D RG cas g&eacute;n&eacute;ral - base
d&eacute;plafonn&eacute;e</small></td>
        <td style="font-family: Arial; text-align: center;"><small><input
 id="base_cg" onchange="resultat_cg();" value="0"
 type="text"></small></td>
        <td
 style="width: 134px; font-family: Arial; text-align: center;"><small><span><input
 id="cg" onchange="resultat_cg();" value="21"
 type="text"></span></small> </td>
        <td
 style="text-align: center; width: 302px; font-family: Arial;"><small><span><input
 id="resultat_cg" value="0" type="text"></span></small>
        </td>
      </tr>
      <tr>
        <td style="font-family: Arial;"><small>100 A
RG cas g&eacute;n&eacute;ral - base plafonn&eacute;e</small></td>
        <td style="font-family: Arial;"></td>
        <td style="font-family: Arial;"></td>
        <td style="font-family: Arial;"></td>
      </tr>
      <tr>
        <td style="font-family: Arial;"><small>236 D
FNAL sur totalit&eacute; des salaires</small></td>
        <td style="font-family: Arial;"></td>
        <td style="font-family: Arial;"></td>
        <td style="font-family: Arial;"></td>
      </tr>
      <tr>
        <td style="font-family: Arial;"><small>260 D
CSG - CRDS R&eacute;gime g&eacute;n&eacute;ral</small></td>
        <td style="font-family: Arial;"></td>
        <td style="font-family: Arial;"></td>
        <td style="font-family: Arial;"></td>
      </tr>
      <tr>
        <td style="font-family: Arial;"><small>671 P
R&eacute;duction Fillon - base plafonn&eacute;e</small></td>
        <td style="font-family: Arial;"></td>
        <td style="font-family: Arial;"></td>
        <td style="font-family: Arial;"></td>
      </tr>
    </tbody>
  </table>
  <br>
  <table style="text-align: left; width: 1153px; height: 118px;"
 border="0" cellpadding="2" cellspacing="2">
    <tbody>
      <tr>
        <td style="font-family: Arial; width: 325px;"><small>Salaires
vers&eacute;s le </small></td>
        <td style="font-family: Arial; width: 187px;"><small><input
 name="date_versement"></small></td>
        <td style="font-family: Arial; width: 68px;"></td>
        <td
 style="background-color: rgb(226, 189, 255); font-family: Arial; width: 177px;"><small>Total
des cotisations</small></td>
        <td
 style="font-family: Arial; width: 358px; text-align: center; background-color: rgb(226, 189, 255);"><small><input
 name="total_cotisations"></small></td>
      </tr>
      <tr>
        <td style="font-family: Arial; width: 325px;"><small>Effectif
au dernier jour de la p&eacute;riode</small></td>
        <td style="font-family: Arial; width: 187px;"><small><input
 name="effectif_fin_periode"></small></td>
        <td style="font-family: Arial; width: 68px;"></td>
        <td
 style="background-color: rgb(226, 189, 255); font-family: Arial; width: 177px;"><small>D&eacute;duction</small></td>
        <td
 style="font-family: Arial; width: 358px; text-align: center; background-color: rgb(226, 189, 255);"><small><input
 name="deduction"></small></td>
      </tr>
      <tr>
        <td style="font-family: Arial; width: 325px;"><small>Effectif
remun&eacute;r&eacute; pour la p&eacute;riode</small></td>
        <td style="font-family: Arial; width: 187px;"><small><input
 name="effectif_remunere_fin"></small></td>
        <td style="font-family: Arial; width: 68px;"></td>
        <td
 style="background-color: rgb(226, 189, 255); font-family: Arial; width: 177px;"><small>Montant
&agrave; payer</small></td>
        <td
 style="font-family: Arial; width: 358px; text-align: center; background-color: rgb(226, 189, 255);"><small><input
 name="montant_a_payer"></small></td>
      </tr>
      <tr>
        <td style="font-family: Arial; width: 325px;"></td>
        <td style="font-family: Arial; width: 187px;"></td>
        <td style="font-family: Arial; width: 68px;"></td>
        <td style="font-family: Arial; width: 177px;"></td>
        <td style="font-family: Arial; width: 358px;"></td>
      </tr>
    </tbody>
  </table>
  <br>
  <table style="text-align: left; width: 1153px; height: 60px;"
 border="0" cellpadding="2" cellspacing="2">
    <tbody>
      <tr>
        <td
 style="width: 328px; font-family: Arial; text-align: center; background-color: rgb(226, 189, 255);"><small>Libell&eacute;
du compte bancaire</small></td>
        <td colspan="4" rowspan="1"
 style="width: 200px; font-family: Arial; text-align: center; background-color: rgb(226, 189, 255);"><small>RIB</small></td>
        <td
 style="width: 398px; font-family: Arial; text-align: center; background-color: rgb(226, 189, 255);"><small>Montant</small></td>
      </tr>
      <tr>
        <td
 style="width: 328px; font-family: Arial; text-align: center;"></td>
        <td
 style="width: 66px; font-family: Arial; text-align: center;"></td>
        <td
 style="width: 68px; font-family: Arial; text-align: center;"></td>
        <td
 style="width: 124px; font-family: Arial; text-align: center;"></td>
        <td
 style="width: 200px; font-family: Arial; text-align: center;"></td>
        <td
 style="width: 398px; font-family: Arial; text-align: center;"></td>
      </tr>
    </tbody>
  </table>
  <br ="">
  <script type="text/javascript"> function somme() { var result = document.getElementById('resultat'); var value1 = document.getElementById('base_at').value; var value2 = (document.getElementById('at').value); if (testInt(value1) && testInt(value2)) { result.value = parseInt(value1) * parseInt(value2) ; } else { alert('Les valeurs introduites ne sont pas des nombres'); } } function testInt(value) { return value == parseInt(value); }</script>
  <script type="text/javascript"> function resultat_cg() { var resultat_cg = document.getElementById('resultat_cg'); var value3 = document.getElementById('base_cg').value; var value4 = (document.getElementById('cg').value); if (testInt(value3) && testInt(value4)) { resultat_cg.value = parseInt(value3) * parseInt(value4) ; } else { alert('Les valeurs introduites ne sont pas des nombres'); } } function testInt(value) { return value == parseInt(value); } </script></form>
</body>
</html>