Comment y remedier car avant cela fonctionnait mais cela marchait que sur la première ligne. Maintenant je dois chaque fois modifier id g et n
Version imprimable
Comment y remedier car avant cela fonctionnait mais cela marchait que sur la première ligne. Maintenant je dois chaque fois modifier id g et n
c'est ce qu'on te répète depuis le début
tu ne peux avoir plusieurs fois le même id
regarde dans le code généré ligne 427, 459 et 491 et bien d'autres encore
tu asL'id est toujours gCode:<input... type="text" id="g" onchange="recalculer();" value="12" size="4">
donc si tu veux le faire sur chaque ligne tu vire g est tu mets un id différent à chaque fois
un id est par définition un identifiant il doit donc identifier l'objet s'il n'est pas unique il n'identifie rien
A+JYT
C'est normal parce que tu appelles la fonction dans le onchange de ces input. La colonne resultat n'est pas pré-calculé au chargement de la page depuis php?
Sinon, je ne vois pas trop l'intérêt de recalculer toutes les lignes si aucune modification de la ligne n'est faite.
A+.
Bonjour autre petit probleme maintenant si je commence avec un nouveau classement j'inscris tous mes clubs et quand j'arrive sur la feuille avec tous mes champs input et que je renseigne la première fois j'ai un message "NaN" qui s'affiche dans ma case input pts, mais les autres calculs des input match jo, input dif cela marche, pourquoi ?
Voici le code pour rappeller
Code:
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 <script language="JavaScript"> <!-- function recalculer(index) { //déclarons trois variables temporaires var val1=0; var val2=0; var val3=0; var val4=0; var val5=0; var val6=0; var val7=0; // et une variable pour le total var total1=val1+val2+val3+val4; var total2=(val1*4)+(val2*2)+val3-val7; var total3=val5-val6; //pour les menus, le test n'est pas nécessaire val1=parseInt(document.getElementById('g'+index).value); val2=parseInt(document.getElementById('n'+index).value); val3=parseInt(document.getElementById('p'+index).value); val4=parseInt(document.getElementById('f'+index).value); val7=parseInt(document.getElementById('pen'+index).value); val5=parseInt(document.getElementById('bc'+index).value); val6=parseInt(document.getElementById('bp'+index).value); //calculons le total total1=val1+val2+val3+val4; total2=(val1*4)+(val2*2)+val3-val7; total3=val5-val6; //plaçons-le dans le chmaps resultat document.getElementById('resultat1'+index).value=total1; document.getElementById('resultat2'+index).value=total2; document.getElementById('resultat3'+index).value=total3; //le tour est joué } </script> <h1>Liste des Classements</h1> <div id="manage_tool"> <a href="index.php?page=classement" title="Ajouter un Match"> <img src="images/ajouter_data.png" /> <span>Ajouter</span> </a> </div> <?php affiche_msg_alert('ajout', 'classement'); affiche_msg_alert('conf', 'classement'); ?> <div id="conteneur_tableau" style="text-align:center"> <form name="match" action="<?php echo _ADMIN_URL.'index.php?page=list-classement'; ?>" id="ajout_dat" method="post"> <fieldset> <legend>Saison : <select name="saison" onChange="document.match.compet_id.value='';document.match.submit()"> <?php $result = get_list_classement(); ?> <option value="">Choisir saison</option> <?php while($compete = mysql_fetch_assoc($result)): ?> <?php if (isset($_POST['saison']) && ($compete['clas_saison']==$_POST['saison'])) {$checked='selected';} else {$checked='';}?> <option value="<?php echo $compete['clas_saison'];?>" <?php echo $checked;?>><?php echo $compete['clas_saison'];?> / <?php echo $compete['clas_saison']+1;?></option> <?php endwhile; ?> </select> Championnat : <select name="compet_id" onChange="document.match.submit()"> <?php if(isset($_POST['saison']) && ($_POST['saison']!='')) $result = get_list_championnat($_POST['saison']); else { $_POST['compet_id']=''; $result = get_list_compete(); } ?> <option value="">Choisir compétitions</option> <?php while($compete = mysql_fetch_assoc($result)): ?> <?php if (isset($_POST['compet_id']) && ($compete['compet_id']==$_POST['compet_id'])) {$checked='selected';} else {$checked='';}?> <option value="<?php echo $compete['compet_id'];?>" <?php echo $checked?>><?php echo $compete['compet_longname']; ?></option> <?php endwhile; ?> </select> </legend> <p> </p> <input type="hidden" name="edition" value="<?php echo (isset($_GET['modif'])) ? $_GET['modif'] : null; ?>" /> <table 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">Nul</th> <th class="points">Perdu</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> <?php if (isset($_POST['saison']) && ($_POST['compet_id']!='')) { $result = get_classement($_POST['saison'],$_POST['compet_id']); } else { } $num_ligne = 1; // initialisation du numero de chaque champs while($match = mysql_fetch_assoc($result) ): ?> <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']; ?>]" class="cl" id="resultat2<?php echo $match['clas_id']; ?>" style="vertical-align:middle" onchange='affich()' value="<?php echo $match['clas_pts'];?>" size="4" readonly="readonly"/></td> <td align="left" nowrap="nowrap"><input name="jo[<?php echo $match['clas_id']; ?>]" class="cl" id="resultat1<?php echo $match['clas_id']; ?>" onchange='affich()'value="<?php echo $match['clas_jo']; ?>" size="4" readonly="readonly" /></td> <td align="left" nowrap="nowrap"><input class="clas" name="g[<?php echo $match['clas_id']; ?>]" type="text" id="g<?php echo $match['clas_id']; ?>" onchange="recalculer(<?php echo $match['clas_id']; ?>);" 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<?php echo $match['clas_id']; ?>" onchange="recalculer(<?php echo $match['clas_id']; ?>);" 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<?php echo $match['clas_id']; ?>" onchange="recalculer(<?php echo $match['clas_id']; ?>);" 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<?php echo $match['clas_id']; ?>" onchange="recalculer(<?php echo $match['clas_id']; ?>);" 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<?php echo $match['clas_id']; ?>" type="text" onchange="recalculer(<?php echo $match['clas_id']; ?>);" 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<?php echo $match['clas_id']; ?>" type="text" onchange="recalculer(<?php echo $match['clas_id']; ?>);" value="<?php echo $match['clas_bp']; ?>" size="4"/></td> <td align="left" nowrap="nowrap"><input name="dif[<?php echo $match['clas_id']; ?>]" class="cl" id="resultat3<?php echo $match['clas_id']; ?>" style="vertical-align:middle" onchange='affich()' value="<?php echo $match['clas_dif'];?>" size="4" readonly="readonly"/></td> <td align="left" nowrap="nowrap"><input class="clas" name="pen[<?php echo $match['clas_id']; ?>]" id="pen<?php echo $match['clas_id']; ?>" onchange='recalculer(<?php echo $match['clas_id']; ?>);' value="<?php echo $match['clas_pen'];?>" size="4" style="vertical-align:middle"/></td> </tr> <?php endwhile; ?> </tbody> </table >