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 :

Liste de formulaires


Sujet :

JavaScript

  1. #1
    Membre confirmé
    Inscrit en
    Juin 2005
    Messages
    171
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 171
    Par défaut Liste de formulaires
    bonsoir j'ai une page php qui affiche une liste de formulaires et dans chak formulaire on doit faire la multiplication de deux champs pour lafficher sur le 3éme voici mon code htlm
    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
     
    <?php if ($error == 0) { ?> 
    <table width="30%" border="0" cellspacing="0" cellpadding="0" class="main" align="center"> 
    <form name="getcountries" action="buy_number.php" method="post">
    <input name="list" value="1" type="hidden">
    <tr> 
        <td colspan="3" align="center" class="theader">&nbsp;</td> 
    </tr> 
    <tr> 
        <td class="datatdh">Select country:</td> 
        <td class="datatd"> 
            <select name="co_id" onChange="this.form.submit();"> 
                <option value="" selected>Select country</option> 
                <?php for ($c =0; $c < count($result);$c++) { ?> 
                    <option value="<?php echo $result[$c]['country_id']; ?>" <?php if ($_POST['co_id'] ==  $result[$c]['country_id']) echo 'selected';?>><?php echo $result[$c]['country_prefix']." - ". $result[$c]['country_name']; ?></option>; 
                <?php } ?> 
            </select> 
        </td> 
        <td class="datatd"><input type="submit" class="bsubmit" name="list"  value="List cities"></td> 
    </tr> 
    </form> 
    </table> 
    <br> 
    <?php if ($error == 0 && count($result2) > 0) { ?> 
    <table width="30%" border="0" cellspacing="0" cellpadding="0" class="main" align="center"> 
    <tr> 
        <td colspan="13" align="center" class="theader" nowrap>&nbsp;</td> 
    </tr> 
    <tr> 
        <td class="datatdt" align="center">City prefix</td>     
        <td class="datatdt" align="center">Cities</td> 
        <td class="datatdt" align="center">Setup</td>
        <td class="datatdt" align="center">Monthly</td>   
         <td class="datatdt" align="center">Periode</td>    
        <td class="datatdt" align="center">Total Price</td> 
        <td class="datatdt">&nbsp;</td> 
    </tr> 
    <?php for($i=0; $i<count($result2); $i++){ 
    ?>
    <form name=order action=order.php method=post > 
     
    <tr> 
        <td class="datatd" align="center" nowrap><?php echo $result2[$i]['city_prefix']; ?></td> 
        <td class="datatd" align="center" nowrap><?php echo $result2[$i]['city_name']; ?></td> 
        <td class="datatd" align="center" nowrap><input type="text" name="setup" value="<?php echo sprintf("%01.2f",5.00*1*1.43); ?>" size="5" readonly></td> 
         <td class="datatd" align="center" nowrap><input type="text" name="monthly" value="<?php echo sprintf("%01.2f",$result2[$i]['monthly']*1*1.43); ?>" size="5" readonly></td> 
          <td class="datatd" align="center" nowrap><select name="period" onChange="cal();"><option value="1">1</option> 
        <option value="3">3</option> 
        <option value="6">6</option> 
        <option value="12">12</option> 
        <option value="24">24</option> 
        </select>
        </td>
        <td class="datatd" align="center" nowrap><input type="text" name="totalamount" value="<?php echo sprintf("%01.2f", ($result2[$i]['monthly']+5)*$currency*1.43); echo ' usd'; ?>" size="5" readonly></td> 
        <td class="datatdt" align="center"> 
            <input type="submit" style="width: 70px" name="order_did" value="Order DID"> 
        </td> 
    </tr> 
    <input type="hidden" name="uniq" value="<?php echo $result2[$i]['uniq'];?>"> 
     
    </form> 
    <?php 
    $_SESSION['uniq'] = $result2[$i]['uniq'];
    } ?> 
    </table> 
    <?php }} ?>
    et voici le code javascript
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    function cal() {
     
     
     var pl=document.this.form.period.value;
     
     var set=document.this.form.setup.value;
      var mon=document.this.form.monthly.value;
     
     var resultat=Math.round((set+mon)pl*100)/100
     document.this.form.totalamount.value=resultat;
     
     }
    quant on fait un select du nombre de période ca doit calculer automatiquement le cout total pour une lign de la liste.
    Je l'ai déja fait pour un seul formulaire mais pas encore pour une liste de formulaire.
    Quelqu'un a-t-il une idée.Merci

  2. #2
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Par défaut
    Et quel est ton problème ?
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  3. #3
    Membre confirmé
    Inscrit en
    Juin 2005
    Messages
    171
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 171
    Par défaut
    le script javascript ne marche pas.le champs 'totalamount' doit étre calculer a partir des champs (setup+monthly)*periode

  4. #4
    Membre confirmé
    Inscrit en
    Juin 2005
    Messages
    171
    Détails du profil
    Informations forums :
    Inscription : Juin 2005
    Messages : 171
    Par défaut
    Ben la solution a été trouvée je poste un script exemple pour ce qui auront le méme probléme:[CODE]
    <script type="text/javascript">
    <html>
    <head>
    <script>


    function cal(id)
    {
    var frm = document.forms["foo"+id]
    frm["totalamount"].value =
    parseFloat(frm["setup"].value) +
    parseFloat(frm["monthly"].value) *
    parseFloat(frm["period"].options[frm["period"].selectedIndex].value);

    var total = 0;
    for (var i =0 ;i <document.forms.length;i++)
    {
    total = total + parseFloat(document.forms[i]["totalamount"].value);
    }

    document.getElementById("total").value=total;

    }
    </script>
    </head>

    <body>
    <table width="30%" border="0" cellspacing="0" cellpadding="0" class="main" align="center">
    <form name="getcountries" method="post">

    <tr>
    <td colspan="3" align="center" class="theader">&nbsp;</td>
    </tr>
    <tr>
    <td class="datatdh">Select country:</td>
    <td class="datatd">
    <select name="co_id" >
    <option value="" selected>Select country</option>

    <option value="1"></option>
    <option value="2"></option>

    </select>
    </td>
    <td class="datatd"><input type="submit" class="bsubmit" name="list" value="List cities"></td>
    </tr>
    </form>
    </table>
    <table width="30%" border="0" cellspacing="0" cellpadding="0" class="main" align="center">
    <tr>
    <td colspan="13" align="center" class="theader" nowrap>&nbsp;</td>
    </tr>
    <tr>

    <td class="datatdt" align="center">Setup</td>
    <td class="datatdt" align="center">Monthly</td>
    <td class="datatdt" align="center">Periode</td>
    <td class="datatdt" align="center">Total Price</td>
    <td class="datatdt">&nbsp;</td>
    </tr>
    <?php for($i=0; $i<5; $i++){
    echo'<form name=foo'.$i.' >';
    ?>
    <tr>

    <td class="datatd" align="center" nowrap><input type="text" name="setup" value="3" readonly></td>
    <td class="datatd" align="center" nowrap><input type="text" name="monthly" value="4" readonly></td>
    <td class="datatd" align="center" nowrap><select name="period" onChange="cal(<?php echo $i?>)"><option value="1">1</option>
    <option value="3">3</option>
    <option value="6">6</option>
    <option value="12">12</option>
    <option value="24">24</option>
    </select>
    </td>
    <td class="datatd" align="center" nowrap><input type="text" name="totalamount" value="12"></td>
    <td class="datatdt" align="center">
    <input type="submit" style="width: 70px" name="order_did" value="Order DID">
    </td>
    </tr>


    </form>
    <?php

    } ?>



    </body>
    </html>

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

Discussions similaires

  1. Réponses: 2
    Dernier message: 04/06/2006, 20h11
  2. liste sur formulaire
    Par milielf dans le forum Access
    Réponses: 10
    Dernier message: 18/05/2006, 15h35
  3. Liste des formulaires dans ListeBox
    Par gbuxo dans le forum Access
    Réponses: 2
    Dernier message: 08/04/2006, 11h23
  4. contrôle des zones de liste dans formulaire
    Par philpaul dans le forum IHM
    Réponses: 4
    Dernier message: 25/11/2005, 23h28

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