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

jQuery Discussion :

Effectuer un total sur un formulaire


Sujet :

jQuery

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Autre
    Inscrit en
    Mars 2013
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Autre
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2013
    Messages : 5
    Par défaut Effectuer un total sur un formulaire
    Bonsoir, voici mon soucis, je suis un débutant.. voir jamais touché au jquery, j'ai donc fait mon formulaire php pour accumuler diverses options étant tarifés, et j'aimerais donc faire un total en temps réel ainsi qu'un total final qui sera retenu par le php pour le prix mensuel, comment y procéder ?

    Voici un extrait de mon code:
    Code html : 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
    <table width="38%" cellspacing="0" cellpadding="0" class="configtable">
    <tr><td class="fieldlabel"><p>Architecture:</p></td><td class="fieldarea">
    <select name="Architecture" onchange="recalctotals()">
    <option value="Select" selected="selected">Séléctionnez </option>
    <option value="32">32 Bits</option>
    <option value="64">64 Bits</option>
    </select>
    </table>
    <br />
    <table width="41%" cellspacing="0" cellpadding="0" class="configtable">
    <tr><td class="fieldlabel"><p>Langue: </p></td><td class="fieldarea">
    <select name="Langue" onchange="recalctotals()">
    <option value="Default" selected="selected">Séléctionnez </option>
    <option value="fr">Français</option>
    <option value="en">Anglais</option>
    <option value="de">Allemand</option>
    <option value="es">Espagnol</option>
    <option value="it">Italien</option>
    <option value="pl">Polonais</option>
    <option value="pt">Portugal</option>
    </select>
    </table>

    Merci d'avance

  2. #2
    Rédacteur

    Avatar de Bovino
    Homme Profil pro
    Développeur Web
    Inscrit en
    Juin 2008
    Messages
    23 647
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Gironde (Aquitaine)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juin 2008
    Messages : 23 647
    Billets dans le blog
    20
    Par défaut
    Je ne vois pas trop l'utilité de jQuery si c'est pour faire une addition de la valeur des champs.

    Sinon, à quoi ressemble ton code ?
    Au pire, dans l'idée, tu récupères la valeur des champs à additionner (dans ton HTML, je vois pas trop desquels il s'agit...), tu additionnes ces valeurs et tu affectes le résultat à un champ hidden qui sera ainsi transmit à PHP.
    Pas de question technique par MP !
    Tout le monde peut participer à developpez.com, vous avez une idée, contactez-moi !
    Mes formations video2brain : La formation complète sur JavaScriptJavaScript et le DOM par la pratiquePHP 5 et MySQL : les fondamentaux
    Mon livre sur jQuery
    Module Firefox / Chrome d'intégration de JSFiddle et CodePen sur le forum

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Autre
    Inscrit en
    Mars 2013
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Suisse

    Informations professionnelles :
    Activité : Autre
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Mars 2013
    Messages : 5
    Par défaut
    Hello, à vrai dire c'est que j'aimerais également que ça donne le résultat en temps réel à l'utilisateur pour qu'il se rendre compte du prix lors de modifications, voici le code entier:
    Code html : 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
    <form size="25" name="monForm" method="post" action="" > 
    <p><span><strong>Séléctionnez votre cycle de paiement:</strong></span><br /> </p>
     <table width="42%" border="0" cellspacing="0" cellpadding="0">
    </table>
    <p><td class="radiofield"><input type="radio" name="Cycle_Facturation" id="cycle1" value="9.90" checked /></td><td class="fieldarea"><label for="cycle1"> €9.90 EUR Mensuel</label></td></p>
    <p><td class="radiofield"><input type="radio" name="Cycle_Facturation" id="cycle2" value="29.00" /></td><td class="fieldarea"><label for="cycle2"> €29.00 EUR Trimestriel</label></td></p>
    <p><td class="radiofield"><input type="radio" name="Cycle_Facturation" id="cycle3" value="59.00" /></td><td class="fieldarea"><label for="cycle3"> €59.00 EUR Semestriel (+1 Mois offert)</label></td></p>
    <p><td class="radiofield"><input type="radio" name="Cycle_Facturation" id="cycle4" value="118.00" /></td><td class="fieldarea"><label for="cycle4"> €118.00 EUR Annuel (+2 Mois offert)</label></td></p>
    <br />
    <p><span><strong>Configuration DNS:</strong></span><br /> </p>
     <table width="42%" border="0" cellspacing="0" cellpadding="0">
    </table>
     <table width="52%" border="0" cellspacing="0" cellpadding="0">
           <td width="80"><p>DNS Primaire:</p></td>
           <td width="70"> <input type="text" size="25" name="DNS" >.speedy-hebergement.com <br />
    </table>
    <br />
    <table width="44%" cellspacing="0" cellpadding="0" class="configtable">
    <tr><td class="fieldlabel"><p>Connexion réseau: </p></td><td class="fieldarea">
    <select name="Memoire_Vive_Additionel" onchange="recalctotals()">
    <option value="Rien" selected="selected">Ne pas modifier la RAM</option>
    <option value="1">+1 GB €5.00 EUR</option>
    <option value="2">+2 GB €10.00 EUR</option>
    <option value="4">+4 GB €20.00 EUR</option>
    <option value="8">+8 GB €35.00 EUR</option>
    <option value="16">+16 GB €65.00 EUR</option>
    <option value="32">+32 GB €120.00 EUR</option>
    </select>
    </td></tr>
    </table>
    <br />
    <p><span><strong>Configuration du serveur</strong></span><br /> </p>
    <table width="58%" cellspacing="0" cellpadding="0" class="configtable">
    <tr><td class="fieldlabel"><p>Système d'exploitation:</p></td><td class="fieldarea">
    <select name="OS" onchange="recalctotals()">
    <option value="Séléctionnez" selected="selected">Séléctionnez</option>
    <option value="FreeBSD 7.4">FreeBSD 7.4</option>
    <option value="FreeBSD 8.3">FreeBSD 8.3</option>
    <option value="FreeBSD 9.1">FreeBSD 9.1</option>
    <option value="Red Hat Ent. Linux 6">Red Hat Ent. Linux 6</option>
    <option value="Solaris SmartOS (Alpha)">Solaris SmartOS (Alpha)</option>
    <option value="CentOS 5">CentOS 5</option>
    <option value="CentOS 6">CentOS 6</option>
    <option value="Debian 6.0 Stable">Debian 6.0 Stable</option>
    <option value="Gentoo 2012">Gentoo 2012</option>
    <option value="Slackware 13">Slackware 13</option>
    <option value="ArchLinux 2012">ArchLinux 2012</option>
    <option value="OpenSUSE 12.2">OpenSUSE 12.2</option>
    <option value="Fedora 17">Fedora 17</option>
    <option value="Mandriva">Mandriva</option>
    <option value="Ubuntu Desktop 12.04">Ubuntu Desktop 12.04</option>
    <option value="Ubuntu Server 12.10">Ubuntu Server 12.10</option>
    <option value="SmartOS (ALPHA)">SmartOS (ALPHA)</option>
    <option value="Windows Server 2012 Standard Edition">Windows Server 2012 Standard Edition €24.90 EUR</option>
    <option value="Windows Server 2012 Datacenter Edition">Windows Server 2012 Datacenter Edition €79.90 EUR</option>
    <option value="Autre">Autre (Précisez note)</option>
    </select>
    </td></tr>
    </table>
    <br />
    <table width="58%" cellspacing="0" cellpadding="0" class="configtable">
    <tr><td class="fieldlabel"><p>Configuration firewall:</p></td><td class="fieldarea">
    <select name="Firewall_Config" onchange="recalctotals()">
    <option value="Rien" selected="selected">Séléctionnez</option>
    <option value="52">Configuration basic offerte</option>
    <option value="53">Configuration high (+€29.90&euro; Frais de configuration)</option>
    </select>
    </td></tr>
    </table>
    <br />
    <table width="44%" cellspacing="0" cellpadding="0" class="configtable">
    <tr><td class="fieldlabel"><p>Connexion réseau: </p></td><td class="fieldarea">
    <select name="Type_Connexion" onchange="recalctotals()">
    <option value="200 Mbps" selected="selected">200 Mbps (Inclus)</option>
    <option value="1 Gbps">1 Gbps (+19.90&euro; Mensuel)</option>
    </select>
    </td></tr>
    </table>
    <br />
    <table width="38%" cellspacing="0" cellpadding="0" class="configtable">
    <tr><td class="fieldlabel"><p>Architecture:</p></td><td class="fieldarea">
    <select name="Architecture" onchange="recalctotals()">
    <option value="Select" selected="selected">Séléctionnez </option>
    <option value="32">32 Bits</option>
    <option value="64">64 Bits</option>
    </select>
    </table>
    <br />
    <table width="41%" cellspacing="0" cellpadding="0" class="configtable">
    <tr><td class="fieldlabel"><p>Langue: </p></td><td class="fieldarea">
    <select name="Langue" onchange="recalctotals()">
    <option value="Default" selected="selected">Séléctionnez </option>
    <option value="fr">Français</option>
    <option value="en">Anglais</option>
    <option value="de">Allemand</option>
    <option value="es">Espagnol</option>
    <option value="it">Italien</option>
    <option value="pl">Polonais</option>
    <option value="pt">Portugal</option>
    </select>
    </table>
    <br />
    <br />
        <p>
        <input type="checkbox" name="accepttos" id="accepttos" />
        <label for="accepttos">J'ai lu et j'accepte les <a href="fr/documents_legaux/index.html" target="_blank">Conditions d'utilisation</a></label>
        .  </p>
     
    	<br />
    <center>
                 <input type="image" id="ok" src="images/ok.png" style="float:padding:15px 8px 0 8px;height:20px" size="25" name="valider" value="s'enregistrer"> <br />
    </center>
             </form> 
     
     
    		         <?php
            include("config.php");
            mysql_select_db("support");
     
            if (isset($_POST['valider'])) {
     
                            $ID_Du_Compte =  $_SESSION['ID']; 
                    $Cycle_Facturation = $_POST['Cycle_Facturation'];
                                    $Architecture = $_POST['Architecture'];
                    $DNS = $_POST['DNS'];
                    $OS = $_POST['OS'];
                                    $Type_Connexion = $_POST['Type_Connexion'];
                                    $Firewall_Config = $_POST['Firewall_Config'];
                                    $Langue = $_POST['Langue'];
                                    $Date_De_Creation = date('Y-m-d H:i:s');
     
     
     
                    $req = MYSQL_QUERY( "INSERT INTO produits
                                         SET ID_Du_Compte = '".mysql_real_escape_string($ID_Du_Compte)."',
                                                                                     Cycle_Facturation = '".mysql_real_escape_string($Cycle_Facturation)."',
                                             Architecture = '".mysql_real_escape_string($Architecture)."',
                                                                     DNS = '".mysql_real_escape_string($DNS).".speedy-hebergement.com',
                                             OS = '".mysql_real_escape_string($OS)."',
                                             Type_Connexion = '".mysql_real_escape_string($Type_Connexion)."',
                                             Firewall_Config = '".mysql_real_escape_string($Firewall_Config)."',
                                             Langue = '".mysql_real_escape_string($Langue)."',
                                             Date_De_Creation = '".mysql_real_escape_string($Date_De_Creation)."',
                                                                                     Premier_Paiement = '".mysql_real_escape_string($Cycle_Facturation)."',
                                                                                     Paiement_Mensuel = '".mysql_real_escape_string($Cycle_Facturation)."',
                                                                                     DDOS_Protection = '1',
                                                         Etat_Produit = '10',
                                                                                     Etat_Premier_Paiement = '0'
                                    ");
                                    
                                $req2 = MYSQL_QUERY( "UPDATE comptes
                                         SET Nombre_Produit = Nombre_Produit + '1'
                                                                             WHERE
                                                                             id = '" . $_SESSION['ID'] . "'
                                    ");
                                    
                                    header ("location: commande.php?p2=1");
                }
            ?>

Discussions similaires

  1. Réponses: 6
    Dernier message: 30/08/2013, 10h42
  2. [WD17] Sur quel formulaire effectuer le SUBMIT ?
    Par zouzoukha dans le forum WinDev
    Réponses: 2
    Dernier message: 07/04/2013, 23h11
  3. Réponses: 9
    Dernier message: 23/06/2008, 15h54
  4. Réponses: 2
    Dernier message: 22/10/2004, 06h50
  5. pb avec des clés sur un formulaire
    Par marie253 dans le forum Bases de données
    Réponses: 7
    Dernier message: 17/06/2004, 13h53

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