Désole en me relisant j'ai vu que j'avais fait une faute entre Java et Javascript.
Donc voila j'ai un script qui calcul 3 input pour afficher le resultat dans un autre input :
Voici mon script :
Code : 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 <script language="JavaScript"> <!-- function recalculer() { //déclarons trois variables temporaires var val1=0; var val2=0; var val3=0; var val4=0; var val5=0; var val6=0; // et une variable pour le total var total1=val1+val2+val3+val4; var total2=val1+val2+val3; var total3=val5-val6; //pour les menus, le test n'est pas nécessaire val1=parseInt(document.getElementById('g').value); val2=parseInt(document.getElementById('n').value); val3=parseInt(document.getElementById('p').value); val4=parseInt(document.getElementById('f').value); val5=parseInt(document.getElementById('bc').value); val6=parseInt(document.getElementById('bp').value); //calculons le total total1=val1+val2+val3+val4; total2<ital>=(val1*4)+val2*2+val3; total3=val5-val6; //plaçons-le dans le chmaps resultat document.getElementById('resultat1').value=total1; document.getElementById('resultat2').value=total2; document.getElementById('resultat3').value=total3; //le tour est joué } </script>
Ensuite voila mon code html avec lequel j'affiche les enregistrements de ma base de donnée.
Donc mon problème j'arrive a afficher mon calcul sur la première ligne de ma liste d'enregistrement mais les autres ne font pas le calcul.
Code : 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 <table </ital>id="table" cellpadding="0" cellspacing="0" class="tabl_view sortable-onload-3 no-arrow rowstyle-alt colstyle-alt paginate-13 max-pages-7 paginationcallback-callbackTest-calculateTotalRating paginationcallback-callbackTest-displayTextInfo sortcompletecallback-callbackTest-calculateTotalRating"> <thead> <tr> <th class="t_edit">Modifier</th> <th class="t_del">Suppr</th> <th class="numid sortable-num">Place</th> <th class="Clubs">Clubs</th> <th class="points">Points</th> <th class="points">Joués</th> <th class="points">Gagné</th> <th class="points">Perdu</th> <th class="points">Nul</th> <th class="points">Forfait</th> <th class="points">BC</th> <th class="points">BP</th> <th class="points">Dif.</th> <th class="points">Pen.</th> </tr> </thead> <tbody><tr> <td align="left" nowrap="nowrap" class="c_mod"><a href="index.php?page=classement&modif=<?php echo $match['clas_id']; ?>" title="Modifier"><img src="images/editer.png" /></a></td> <td align="left" nowrap="nowrap" class="c_del"><a href="index.php?page=list-classement&suppr=<?php echo $match['clas_id']; ?>" title="Supprimer" onclick="return(confirm('Etes-vous sûr de vouloir supprimer cette entrée?'));"><img src="images/corbeille.gif" /></a></td> <td align="left" nowrap="nowrap" class="t_num"><?php echo $num_ligne++; ?></td> <td align="left" nowrap="nowrap"><?php echo $match['clas_club']; ?></td> <td align="left" nowrap="nowrap"><input name="pts[<?php echo $match['clas_id']; ?>]" id="resultat2" onchange='affich()' value="<?php echo $match['clas_pts'];?>" size="4" style="vertical-align:middle"/></td> <td align="left" nowrap="nowrap"><input class="clas" name="jo[<?php echo $match['clas_id']; ?>]" id="resultat1" onchange='affich()'value="<?php echo $match['clas_jo']; ?>" size="4" /></td> <td align="left" nowrap="nowrap"><input class="clas" name="g[<?php echo $match['clas_id']; ?>]" type="text" id="g" onchange="recalculer();" value="<?php echo $match['clas_g']; ?>" size="4"></td> <td align="left" nowrap="nowrap"><input class="clas" name="n[<?php echo $match['clas_id']; ?>]" type="text" id="n" onchange="recalculer();" value="<?php echo $match['clas_n']; ?>" size="4"></td> <td align="left" nowrap="nowrap"><input class="clas"name="p[<?php echo $match['clas_id']; ?>]" type="text" id="p" onchange="recalculer();" value="<?php echo $match['clas_p']; ?>" size="4"></td> <td align="left" nowrap="nowrap"><input class="clas" name="f[<?php echo $match['clas_id']; ?>]" type="text" id="f" onchange="recalculer();" value="<?php echo $match['clas_f']; ?>" size="4"></td> <td align="left" nowrap="nowrap"><input class="clas" name="bc[<?php echo $match['clas_id']; ?>]" id="bc" type="text" onchange="recalculer();" value="<?php echo $match['clas_bc']; ?>" size="4"/></td> <td align="left" nowrap="nowrap"><input class="clas" name="bp[<?php echo $match['clas_id']; ?>]" id="bp" type="text" onchange="recalculer();" value="<?php echo $match['clas_bp']; ?>" size="4"/></td> <td align="left" nowrap="nowrap"><input class="clas" name="dif[<?php echo $match['clas_id']; ?>]" id="resultat3" onchange='affich()' value="<?php echo $match['clas_dif'];?>" size="4" style="vertical-align:middle"/></td> <td align="left" nowrap="nowrap"><input class="clas" name="pen[<?php echo $match['clas_id']; ?>]" type="text" value="<?php echo $match['clas_pen']; ?>" size="4"/></td> </tr> <?php endwhile; ?> </tbody> </table > </code>
Merci d'avance
Partager