IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JavaScript Discussion :

js qui marche sous IE mais pas FF : pourquoi ?


Sujet :

JavaScript

  1. #1
    Membre Expert
    Avatar de laurentSc
    Homme Profil pro
    Webmaster débutant perpétuel !
    Inscrit en
    Octobre 2006
    Messages
    10 486
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster débutant perpétuel !
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2006
    Messages : 10 486
    Billets dans le blog
    1
    Par défaut js qui marche sous IE mais pas FF : pourquoi ?
    Le code suivant :
    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
    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 ?

  2. #2
    Inactif
    Profil pro
    Inscrit en
    Novembre 2002
    Messages
    117
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2002
    Messages : 117
    Par défaut
    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à

  3. #3
    Membre émérite Avatar de 10_GOTO_10
    Profil pro
    Inscrit en
    Juillet 2004
    Messages
    890
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2004
    Messages : 890
    Par défaut
    Ah et puis:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    parseFloat(parseFloat(...
    il y a un parseFloat de trop, là

  4. #4
    Membre Expert
    Avatar de laurentSc
    Homme Profil pro
    Webmaster débutant perpétuel !
    Inscrit en
    Octobre 2006
    Messages
    10 486
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 61
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster débutant perpétuel !
    Secteur : Industrie

    Informations forums :
    Inscription : Octobre 2006
    Messages : 10 486
    Billets dans le blog
    1
    Par défaut
    Merci, il manquait effectivement un id et IE s'en foutait !

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. script qui marche sous ie mais pas sous firefox
    Par sebicool dans le forum Général JavaScript
    Réponses: 18
    Dernier message: 24/05/2007, 00h07
  2. Script qui marche sous FF mais pas sous IE
    Par xclam dans le forum Général JavaScript
    Réponses: 27
    Dernier message: 11/05/2007, 12h26
  3. Fonction qui marche sous FF mais pas IE
    Par Oluha dans le forum Général JavaScript
    Réponses: 5
    Dernier message: 25/01/2006, 14h07
  4. Pb sur une fct qui marche sous mozilla mais pas ie
    Par chpog dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 21/09/2005, 11h26
  5. Réponses: 2
    Dernier message: 04/06/2004, 11h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo