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 :

Débutante cherche solution addition et multiplication avec virgule


Sujet :

JavaScript

  1. #1
    Nouveau Candidat au Club
    Femme Profil pro
    Responsable Radio
    Inscrit en
    Août 2015
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Responsable Radio

    Informations forums :
    Inscription : Août 2015
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Débutante cherche solution addition et multiplication avec virgule
    Bonjour à toutes et tous,
    je suis dans l'impasse et ce n'est pas faute d'avoir chercher.
    Je souhaite mettre en place des calculs simples dans une de mes pages HTML. J'ai un problème de calcul avec la virgule qui n'ai pas pris en compte! Parfois ça marche et parfois le parseFloat fait des siennes. Je n'arrive pas à trouver l'erreur.
    Merci pour votre aide.

    Voici le code javascript que j'ai mis dans mon HEAD:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <script language="javascript"> 
      function calcul_prix() 
      { 
      Total1.value = parseFloat(Quant1.value*Article1.value) + parseFloat(Quant1.value*"1.45"); 
      Total2.value = parseFloat(Quant2.value*Article2.value) + parseFloat(Quant2.value*"1.05");
      Total3.value = parseFloat(Quant3.value*Article3.value) + parseFloat(Quant3.value*"1.45"); 
      Total.value = parseFloat(Total1.value) + parseFloat(Total2.value) + parseFloat(Total3.value)
    } </script>
     
    Et voici ce que j'ai mis dans mon BODY :
    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
     
    <table style="width: 566px; height: 317px; text-align: left; margin-left: auto; margin-right: auto;" border="1" cellpadding="1" cellspacing="1">
     
        <tbody>
     
          <tr>
     
            <td style="text-align: center; width: 210px;" colspan="1" rowspan="1">Artistes<span style="font-style: italic;"></span></td>
     
            <td style="text-align: center;">Choix <br>
     
    valid&eacute;</td>
     
            <td style="text-align: center;">Prix</td>
     
            <td style="text-align: center;">Quantit&eacute;</td>
     
            <td style="width: 80px; text-align: center;">Total
    avec frais d'envoi</td>
     
          </tr>
     
          <tr>
     
            <td style="width: 269px; text-align: center;"> <a class="fancybox" href="image/jaquettes-boutique/3SCOBAR_bg.jpg" title=""><img style="border: 0px solid ; width: 100px; height: 100px;" src="image/jaquettes-boutique/3SCOBAR_b.jpg" alt=""></a>
            <br>
     
            </td>
     
            <td style="text-align: center;"> <input name="Article1" id="Article1" value="10.00" type="checkbox"> </td>
     
            <td style="text-align: center;">10&euro;</td>
     
            <td style="text-align: center;">
            <select name="Quant1" id="Quant1" onchange="calcul_prix()">
            <option value="0" selected="selected">0</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            </select>
     
            </td>
     
            <td style="width: 80px; text-align: center;"> <input name="Total1" id="Total1" onchange="calcul_prix()" value="0.00" size="2">&euro; </td>
     
          </tr>
     
          <tr>
     
            <td style="width: 269px; text-align: center;"><a class="fancybox" href="image/jaquettes-boutique/AlmaEncriada_bg.jpg" title=""><img style="border: 0px solid ; width: 100px; height: 100px;" src="image/jaquettes-boutique/AlmaEncriada_b.jpg" alt=""></a>
            <br>
     
            </td>
     
            <td style="text-align: center;"> <input name="Article2" id="Article2" value="6.00" type="checkbox"> </td>
     
            <td style="text-align: center;">6&euro;</td>
     
            <td style="text-align: center;">
            <select name="Quant2" id="Quant2" onchange="calcul_prix()">
            <option value="0" selected="selected">0</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            <option value="6">6</option>
            <option value="7">7</option>
            <option value="8">8</option>
            <option value="9">9</option>
            <option value="10">10</option>
            </select>
     
            </td>
     
            <td style="width: 80px; text-align: center;"> <input name="Total2" id="Total2" onchange="calcul_prix()" value="0.00" size="2">&euro; </td>
     
          </tr>
     
          <tr>
     
            <td style="width: 269px; text-align: center;"><a class="fancybox" href="image/jaquettes-boutique/Antidoxe_bg.jpg" title=""><img style="border: 0px solid ; width: 100px; height: 100px;" src="image/jaquettes-boutique/Antidoxe_b.jpg" alt=""></a>
            <br>
     
            </td>
     
            <td style="text-align: center;"> <input name="Article3" id="Article3" value="7.00" type="checkbox"> </td>
     
            <td style="text-align: center;">7&euro;</td>
     
            <td style="text-align: center;">
            <select name="Quant3" id="Quant3" onchange="calcul_prix()">
            <option value="0" selected="selected">0</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
            <option value="5">5</option>
            </select>
     
            </td>
     
            <td style="width: 80px; text-align: center;"> <input name="Total3" id="Total3" onchange="calcul_prix()" value="0.00" size="2">&euro; </td>
     
          </tr>
     
          <tr>
     
            <td style="width: 269px; text-align: center;"></td>
     
            <td style="text-align: center;"></td>
     
            <td style="text-align: center;"></td>
     
            <td style="text-align: center;"></td>
     
            <td style="width: 80px; text-align: center;"><input name="Total" id="Total" onchange="calcul_prix()" value="0.00" size="2">&euro; </td>
     
          </tr>
       </tbody>
      </table>

  2. #2
    Rédacteur/Modérateur

    Avatar de SpaceFrog
    Homme Profil pro
    Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Inscrit en
    Mars 2002
    Messages
    39 637
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Royaume-Uni

    Informations professionnelles :
    Activité : Développeur Web Php Mysql Html Javascript CSS Apache - Intégrateur - Bidouilleur SharePoint
    Secteur : Industrie

    Informations forums :
    Inscription : Mars 2002
    Messages : 39 637
    Points : 66 656
    Points
    66 656
    Billets dans le blog
    1
    Ma page Developpez - Mon Blog Developpez
    Président du CCMPTP (Comité Contre le Mot "Problème" dans les Titres de Posts)
    Deux règles du succès: 1) Ne communiquez jamais à quelqu'un tout votre savoir...
    Votre post est résolu ? Alors n'oubliez pas le Tag

    Venez sur le Chat de Développez !

  3. #3
    Nouveau Candidat au Club
    Femme Profil pro
    Responsable Radio
    Inscrit en
    Août 2015
    Messages
    2
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Responsable Radio

    Informations forums :
    Inscription : Août 2015
    Messages : 2
    Points : 1
    Points
    1
    Par défaut
    Merci je viens de trouver mon erreur.
    En vous souhaitant une excellente fin de journée

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

Discussions similaires

  1. Réponses: 4
    Dernier message: 06/09/2014, 13h38
  2. cherche solution avec jQuery Address Tabs
    Par arnotw dans le forum jQuery
    Réponses: 1
    Dernier message: 14/05/2010, 10h29
  3. cherche solution hebergement avec Graphviz
    Par menthol34 dans le forum Hébergement
    Réponses: 1
    Dernier message: 04/03/2010, 11h36
  4. Débutant cherche solution
    Par slimak dans le forum Servlets/JSP
    Réponses: 22
    Dernier message: 23/03/2009, 10h04
  5. [Système] Cherche solution pour coupler PHP avec UNIX
    Par Delphy113 dans le forum Langage
    Réponses: 4
    Dernier message: 05/10/2006, 16h32

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