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 :

Calcul marche sur IE mais pas sur Firefox


Sujet :

JavaScript

  1. #1
    Inscrit
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    302
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 302
    Points : 151
    Points
    151
    Par défaut Calcul marche sur IE mais pas sur Firefox
    Bonjour,

    J'ai une formule de calcule qui marche sur internet explorer mais pas sur FireFox, Je parle du calcul TOTAL qui ne ce fait pas sur FireFox.

    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
     
    function exporter<?=$i?>() {
    var choix=document.getElementById("vc_ln");
    document.forms["fmaddFacture"].elements["d<?=$i?>"].value=choix.value;
    var choix=document.getElementById("vc_cpn");
    document.forms["fmaddFacture"].elements["p<?=$i?>"].value=choix.value;
    var choix=document.getElementById("vc_pn");
    document.forms["fmaddFacture"].elements["n<?=$i?>"].value=choix.value;
    var choix=document.getElementById("vc_em");
    document.forms["fmaddFacture"].elements["ta<?=$i?>"].value=choix.value;
    var total;
     
    $TotalavantTVA = $('n<?=$i?>').value * $('p<?=$i?>').value;
    $TotalTVA= $('n<?=$i?>').value*$('p0').value/100*$('ta<?=$i?>').value ;
    $('to<?=$i?>').value = $TotalavantTVA + $TotalTVA;
    $('to<?=$i?>').value = Math.round($('to<?=$i?>').value*100) / 100;
    redoTotal(); 
    }

    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
     
    function redoTotal(){
    var rlt = 0;
    var to = 0;
    var n = 0;
    var p = 0;
    var ta = 0;
    var tot_tax=0;
    var tot_bt=0; //before tax.
    for(var i=0; i< <?=$rowed2?>; i++){
    to = 1*eval("document.fmaddFacture.to"+i+".value");
    rlt = rlt + to;
    //tax
    n = 1*eval("document.fmaddFacture.n"+i+".value");
    p = 1*eval("document.fmaddFacture.p"+i+".value");
    tot_bt = tot_bt + 1*n*p;
    ta = 1*eval("document.fmaddFacture.ta"+i+".value");
    tot_tax = tot_tax+1*n*p*ta;
    }
    rlt = formatAsMoney(rlt);
    tot_tax = formatAsMoney(tot_tax);
    tot_bt = formatAsMoney(tot_bt);
    document.fmaddFacture.totbt.value = tot_bt;
    document.fmaddFacture.total.value = rlt;
    //if exact tax based on grand total, not subtotal, uncomment the following line.
    tot_tax = formatAsMoney(rlt - tot_bt);
    document.fmaddFacture.tottax.value = tot_tax;
    }

    Pouvez-vous m'aider SVP

    Merci d'avance

  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 640
    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 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    que te retourne la consle d'erreurs ?

    sinon déja à éviter :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    to = 1*eval("document.fmaddFacture.to"+i+".value");
    mieux vaut :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    to = 1*document.forms['fmaddFacture'].elements['to'+i].value;

  3. #3
    Inscrit
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    302
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 302
    Points : 151
    Points
    151
    Par défaut
    Bonjour,

    Merci de m'avoir répondu

    donc la console me retourne une erreur:
    Erreur : $("n0") has no properties
    Toute est ok avec ce champ

    Puis je ne comprend pas car en dur ça marche comme ce-ci

    1 = quantité (n<?=$i?> le champ quantité)
    10 = prix (p<?=$i?> le champ prix)
    19.6 = TVA (ta<?=$i?> le champ TVA)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    $TotalavantTVA = 1 * 10;
    $TotalTVA= 1*10/100*19.6 ;
    $total = $TotalavantTVA + $TotalTVA;
    $('to<?=$i?>').value = Math.round($total *100) / 100;



    Puis la ça ne marche pas ? mais sur IE ca fonction très bien et très rapidement


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    $TotalavantTVA = $('n<?=$i?>').value * $('p<?=$i?>').value;
    $TotalTVA= $('n<?=$i?>').value*$('p<?=$i?>').value/100*$('ta<?=$i?>').value ;
    $('to<?=$i?>').value = $TotalavantTVA + $TotalTVA;
    $('to<?=$i?>').value = Math.round($('to<?=$i?>').value*100) / 100;

  4. #4
    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 640
    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 640
    Points : 66 663
    Points
    66 663
    Billets dans le blog
    1
    Par défaut
    notation php ...
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $('to<?php echo $i; ?>').value

    et puis par sécurité ...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $TotalavantTVA = ($('n<?=$i?>').value*1) * ($('p<?=$i?>').value*1);
    à repercuter partout ...

  5. #5
    Inscrit
    Profil pro
    Inscrit en
    Septembre 2005
    Messages
    302
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2005
    Messages : 302
    Points : 151
    Points
    151
    Par défaut
    Bonjour,

    Voila vous allez surement rigoler mais je n'avais pas le choix.

    Au lieux de qui ne fonctionne que sur IE


    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
     
    function exporter<?=$i?>() {
    var choix=document.getElementById("vc_ln");
    document.forms["fmaddFacture"].elements["d<?=$i?>"].value=choix.value;
    var choix=document.getElementById("vc_cpn");
    document.forms["fmaddFacture"].elements["p<?=$i?>"].value=choix.value;
    var choix=document.getElementById("vc_pn");
    document.forms["fmaddFacture"].elements["n<?=$i?>"].value=choix.value;
    var choix=document.getElementById("vc_em");
    document.forms["fmaddFacture"].elements["ta<?=$i?>"].value=choix.value;
    var total;
     
    $TotalavantTVA = $('n<?=$i?>').value * $('p<?=$i?>').value;
    $TotalTVA= $('n<?=$i?>').value*$('p0').value/100*$('ta<?=$i?>').value ;
    $('to<?=$i?>').value = $TotalavantTVA + $TotalTVA;
    $('to<?=$i?>').value = Math.round($('to<?=$i?>').value*100) / 100;
    redoTotal(); 
    }
    Donc j'ai écrit un petit soft en VB qui ma générer plus de 10,000 ligne de ce genre

    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
     
    function envoi_0() {
    document.forms["fmaddFacture"].elements['d0'].value = document.forms["fmaddFacture"].elements['vc_ln'].value;
    document.forms["fmaddFacture"].elements['n0'].value = document.forms["fmaddFacture"].elements['vc_pn'].value;
    document.forms["fmaddFacture"].elements['p0'].value = document.forms["fmaddFacture"].elements['vc_cpn'].value;
    document.forms["fmaddFacture"].elements['ta0'].value = document.forms["fmaddFacture"].elements['vc_em'].value;
    $TotalavantTVA = document.forms["fmaddFacture"].elements['n0'].value * document.forms["fmaddFacture"].elements['p0'].value;
    $TotalTVA= document.forms["fmaddFacture"].elements['n0'].value*document.forms["fmaddFacture"].elements['p0'].value/100*document.forms["fmaddFacture"].elements['ta0'].value ;
    document.forms["fmaddFacture"].elements['to0'].value = $TotalavantTVA + $TotalTVA;
    document.forms["fmaddFacture"].elements['to0'].value = Math.round(document.forms["fmaddFacture"].elements['to0'].value*100) / 100;
    redoTotal(); 
    }
     
    function envoi_1() {
    document.forms["fmaddFacture"].elements['d1'].value = document.forms["fmaddFacture"].elements['vc_ln'].value;
    document.forms["fmaddFacture"].elements['n1'].value = document.forms["fmaddFacture"].elements['vc_pn'].value;
    document.forms["fmaddFacture"].elements['p1'].value = document.forms["fmaddFacture"].elements['vc_cpn'].value;
    document.forms["fmaddFacture"].elements['ta1'].value = document.forms["fmaddFacture"].elements['vc_em'].value;
    $TotalavantTVA = document.forms["fmaddFacture"].elements['n1'].value * document.forms["fmaddFacture"].elements['p1'].value;
    $TotalTVA= document.forms["fmaddFacture"].elements['n1'].value*document.forms["fmaddFacture"].elements['p1'].value/100*document.forms["fmaddFacture"].elements['ta1'].value ;
    document.forms["fmaddFacture"].elements['to1'].value = $TotalavantTVA + $TotalTVA;
    document.forms["fmaddFacture"].elements['to1'].value = Math.round(document.forms["fmaddFacture"].elements['to1'].value*100) / 100;
    redoTotal(); 
    }
    Puis

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    <script type="text/javascript" src="_js_/cal_champ.js"></script>
    Et


    ETC...


    Mais ça fonction, en espèrent que je n'aurais pas a faire une facture de 1000 articles LOL

    Merci a toi SpaceFrog

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

Discussions similaires

  1. Un lien marche sur IE mais pas sur Firefox
    Par Arsofts dans le forum Balisage (X)HTML et validation W3C
    Réponses: 5
    Dernier message: 12/07/2009, 15h33
  2. Positionnement d'un background qui marche sur FF mais pas sur IE6
    Par webstarfrog dans le forum Mise en page CSS
    Réponses: 5
    Dernier message: 17/07/2008, 10h23
  3. [MySQL] BDD marche en local mais pas sur free
    Par TOSCAN dans le forum PHP & Base de données
    Réponses: 7
    Dernier message: 21/05/2008, 14h06
  4. Réponses: 1
    Dernier message: 28/03/2007, 19h20
  5. Marche sous FF mais pas sur IE...
    Par benjiiim dans le forum Général JavaScript
    Réponses: 2
    Dernier message: 01/11/2005, 10h54

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