Précédent   Forum des professionnels en informatique > Webmasters - Développement Web > JavaScript
JavaScript Forum programmation JavaScript. Lire : Cours JavaScript, FAQ JavaScript, Toutes les FAQ JavaScript et Sources JavaScript
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
Vieux 19/03/2010, 00h00   #1
Débutant
 
Homme Laurent
Webmaster
Inscription : octobre 2006
Messages : 2 727
Détails du profil
Informations personnelles :
Nom : Homme Laurent
Âge : 47
Localisation : France, Isère (Rhône Alpes)

Informations professionnelles :
Activité : Webmaster
Secteur : Industrie

Informations forums :
Inscription : octobre 2006
Messages : 2 727
Points : 1 237
Points : 1 237
Par défaut js qui marche sous IE mais pas FF : pourquoi ?

Le code suivant :
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
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>devis4</title>
</head>
<body>
<br>
<br>
<br>
<br>
<br>
<script language="javascript" type="text/javascript">
 
 
 
 
function calc_sous_total(prix, qte, type)
{
    sous_total=prix*qte;
    document.getElementById("total_"+type).value=sous_total;
 
    calc_total();
}
 
function calc_total()
{   total_fr = (document.getElementById("total_fr").value!="") ? document.getElementById("total_fr").value : 0;
	total_npn = (document.getElementById("total_npn").value!="") ? document.getElementById("total_npn").value : 0;
	total_npa = (document.getElementById("total_npa").value!="") ? document.getElementById("total_npa").value : 0;
	total_d = (document.getElementById("total_d").value!="") ? d=document.getElementById("total_d").value : 0;
	total=parseFloat(parseFloat(total_fr,10)+parseFloat(total_npn,10)+parseFloat(total_npa,10)+parseFloat(total_d,10));
 
    document.getElementById("total").value=total;
}
 
 
</script>
<script language="javascript" type="text/javascript">
total=0;
</script>
 
<form action="" name="form" method="post">
 <table bgcolor="C596FF">
    <tbody>
      <tr>
        <td colspan="4" bgcolor="black"><font
 color="white" face="Arial">Remplissez les champs
utiles</font> </td>
      </tr>
      <tr bgcolor="grey">
        <td><font color="white" face="Arial">1-
Tarif de base</font></td>
        <td><font color="white" face="Arial">Prix
unitaire</font></td>
        <td><font color="white" face="Arial">Quantit&eacute;</font></td>
        <td><font color="white" face="Arial">Total</font></td>
      </tr>
      <tr>
        <td><font color="white" face="Arial"
 size="2">Frais
de r&eacute;alisation (gratuit) :</font></td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="40"></td>
              <td><input size="5" maxlength="10" name="px_fr"
 value="0" type="text" disabled="disabled">&euro;</td>
              <td width="40"></td>
            </tr>
          </tbody>
        </table>
        </td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="50"></td>
              <td><input size="2" maxlength="10" name="q_fr"
 value="1" type="text" disabled="disabled"></td>
              <td width="50"></td>
            </tr>
          </tbody>
        </table>
        </td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="40"></td>
              <td><input size="5" maxlength="10" name="total_fr"
 value="0" type="text"></td>
              <td width="40">&euro;</td>
            </tr>
          </tbody>
        </table>
        </td>
      </tr>
      <tr bgcolor="grey">
        <td><font color="white" face="Arial">2-
Vos choix</font></td>
        <td></td>
        <td></td>
        <td></td>
      </tr>
     <tr>
        <td><font color="white" face="Arial"
 size="2">Nombres
de photos numériques :</font></td>
        <td>	
 <table>
          <tbody>
            <tr>
              <td width="40"></td>
              <td><input size="5" maxlength="10"
 value="0.9" name="px_npn" type="text" disabled="disabled">&euro;</td>
              <td width="40"></td>
            </tr>
          </tbody>
        </table>
        </td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="50"></td>
              <td><input size="2" maxlength="10"
 value="" name="q_npn" id="q_npn" type="text" onkeyup="calc_sous_total(px_npn.value, this.value, 'npn')"></td>
              <td width="50"></td>
            </tr>
          </tbody>
        </table>		
 
        </td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="40"></td>
              <td><input size="5" maxlength="10"
 value="0" name="total_npn" id="total_npn"  type="text"></td>
              <td width="40">&euro;</td>
            </tr>
          </tbody>
        </table>
        </td>
 
      </tr>
      <tr>
        <td><font color="white" face="Arial"
 size="2">Nombres
de photos argentiques (papier) :</font></td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="40"></td>
              <td><input size="5" maxlength="10"
 value="1.1" name="px_npa" type="text" disabled="disabled">&euro;</td>
              <td width="40"></td>
            </tr>
          </tbody>
        </table>
        </td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="50"></td>
              <td><input size="2" maxlength="10"
 value="" name="q_npa" id="q_npa" type="text" onkeyup="calc_sous_total(px_npa.value, this.value, 'npa')"></td>
              <td width="50"></td>
            </tr>
          </tbody>
        </table>
        </td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="40"></td>
              <td><input size="5" maxlength="10"
 value="0" name="total_npa" id="total_npa"  type="text"></td>
              <td width="40">&euro;</td>
            </tr>
          </tbody>
        </table>
        </td>
 
      </tr>
      <tr>
        <td><font color="white" face="Arial"
 size="2">Nombres
de diapositives
:</font></td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="40"></td>
              <td><input size="5" maxlength="10"
 value="2.0" name="px_d" type="text" disabled="disabled">&euro;</td>
              <td width="40"></td>
            </tr>
          </tbody>
        </table>
        </td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="50"></td>
              <td><input size="2" maxlength="10"
 value="" name="q_d" id="q_d" type="text" onkeyup="calc_sous_total(px_d.value, this.value, 'd')"></td>
              <td width="50"></td>
            </tr>
          </tbody>
        </table>
        </td>
        <td>
        <table>
          <tbody>
            <tr>
              <td width="40"></td>
              <td><input size="5" maxlength="10"
 value="0" name="total_d" id="total_d" type="text" ></td>
              <td width="40">&euro;</td>
            </tr>
          </tbody>
        </table>
        </td>
      </tr>
	  <tr bgcolor=grey><td></td><td></td><td>Total (TTC)</td> <td><input size="5" maxlength="10" value="0"
 name="total" id="total" type="text"></td></tr>
    </tbody>
</td></tr>  </table>
  <br>
  <br>
 
</form>
 
 
</body>
</html>
marche sous IE mais pas sous FF. En gros, c'est pour faire un devis (Ce n'est qu'un essai ; ce n'est pas fini). Que faut-il faire pour que ça marche ?

Dernière modification par Sendusha ; 07/06/2011 à 19h39.
laurentSc est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/03/2010, 02h22   #2
Inactif
 
Inscription : novembre 2002
Messages : 117
Détails du profil
Informations forums :
Inscription : novembre 2002
Messages : 117
Points : 123
Points : 123
ce qu'il faut faire c'est apprendre le JS
Plus sérieusement, tu mets des NAME à tes champs, et tu essayes d'y accéder par document.getElementById().
Le nom de cette méthode dit clairement qu'elle prend l'élément qui a l'id passé en paramètre.

tu mets des id sur tes champs et c'est réglé. Si ça marche sous IE c'est que IE est une bouse permissive. Et tout d'abord il faut coder sous Firefox puis ensuite faire 2/3 fix pour IE mais surtout pas l'inverse.

PS : installer firebug tu verras d'ou viennent tes problèmes.

Ah et Apprendre aussi le HTML et la CSS, il y en a grand besoin là
Gatsu35 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/03/2010, 03h07   #3
Membre émérite
 
Avatar de 10_GOTO_10
 
Inscription : juillet 2004
Messages : 702
Détails du profil
Informations forums :
Inscription : juillet 2004
Messages : 702
Points : 829
Points : 829
Ah et puis:
Code :
parseFloat(parseFloat(...
il y a un parseFloat de trop, là
__________________
Sondages gratuits : Le troc d'opinions
10_GOTO_10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 19/03/2010, 11h03   #4
Débutant
 
Homme Laurent
Webmaster
Inscription : octobre 2006
Messages : 2 727
Détails du profil
Informations personnelles :
Nom : Homme Laurent
Âge : 47
Localisation : France, Isère (Rhône Alpes)

Informations professionnelles :
Activité : Webmaster
Secteur : Industrie

Informations forums :
Inscription : octobre 2006
Messages : 2 727
Points : 1 237
Points : 1 237
Merci, il manquait effectivement un id et IE s'en foutait !
laurentSc est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +1. Il est actuellement 01h02.


 
 
 
 
Partenaires

Hébergement Web