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 :

Aide Pour envoi par mail d'un résultat


Sujet :

JavaScript

  1. #1
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Aide Pour envoi par mail d'un résultat
    Bonjour à tous, je suis plutôt débutant en PHP & HTML et j'ai, plus ou moins, réussi à réaliser une page permettant de réaliser un devis. L'utilisateur sélectionne ce dont il a besoin et le tarif s'affiche en bas de page. J'aimerais pouvoir obtenir par mail les éléments qu'il a sélectionné ainsi que son adresse mail qu'il saisirait dans un champ différent. Mais c'est là que je bug et ne trouve pas du tout la solution. Toute aide serait bien évidemment plus que la bienvenue !

    Merci à tous

    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
    <script type="text/javascript"> 
     
    // Calculate the total for items in the form which are selected. 
    function calculateTotal(inputItem) 
    { 
    with (inputItem.form) 
    { 
    // Process each of the different input types in the form. 
    if (inputItem.type == "radio") 
    { // Process radio buttons. 
     
    // Subtract the previously selected radio button value from the total. 
    calculatedTotal.value = eval(calculatedTotal.value) - eval(previouslySelectedRadioButton.value); 
     
    // Save the current radio selection value. 
    previouslySelectedRadioButton.value = eval(inputItem.value); 
     
    // Add the current radio button selection value to the total. 
    calculatedTotal.value = eval(calculatedTotal.value) + eval(inputItem.value); 
    } 
     
    else 
    { // Process check boxes. 
    if (inputItem.checked == false) 
    { // Item was uncheck. Subtract item value from total. 
    calculatedTotal.value = eval(calculatedTotal.value) - eval(inputItem.value); 
    } 
     
    else 
    { // Item was checked. Add the item value to the total. 
    calculatedTotal.value = eval(calculatedTotal.value) + eval(inputItem.value); 
    } 
    } 
     
    // Total value should never be less than 0. 
    if (calculatedTotal.value < 0) { 
    InitForm(); 
    } 
     
    // Return total value. 
    return(formatCurrency(calculatedTotal.value)); 
    } 
    } 
     
    // Format a value as currency. 
    function formatCurrency(num) { 
    num = num.toString().replace(/\$|\,/g,''); 
    if(isNaN(num)) 
    num = "0"; 
    sign = (num == (num = Math.abs(num))); 
    num = Math.floor(num*100+0.50000000001); 
    cents = num%100; 
    num = Math.floor(num/100).toString(); 
    if(cents<10) 
    cents = "0" + cents; 
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++) 
    num = num.substring(0,num.length-(4*i+3)) + ',' + num.substring(num.length-(4*i+3)); 
    return (((sign)?'':'-') + '€' + num + '.' + cents); 
    } 
     
    // This function initialzes all the form elements to default values. 
    function InitForm() { 
    // Reset values on form. 
    document.selectionForm.total.value='€0'; 
    document.selectionForm.calculatedTotal.value=0; 
    document.selectionForm.previouslySelectedRadioButton.value=0; 
     
    // Set all checkboxes and radio buttons on form to unchecked. 
    for (i=0; i < document.selectionForm.elements.length; i++) { 
    if (document.selectionForm.elements[i].type == 'checkbox' | document.selectionForm.elements[i].type == 'radio') { 
    document.selectionForm.elements[i].checked = false; 
    } 
    } 
    } 
    </script> 
     
    </head> 
    <body onload="InitForm();" onreset="InitForm();"> 
    <div> 
    <table><tr><td> 
    <form method="POST" name="selectionForm"> 
    <a href="../img/diametre_bobines.jpg" rel="lightbox"><img src="../img/encart_numerisation_tarifs.jpg" alt="" name="" width="469" height="53" border="0"/></a><br /> 
    <b> 
    <input type="checkbox" name="Montage K7 récente" value="29.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/montage.jpg" rel="lightbox"> Montage + DVD (DV, VHS, DVD, Disque Dur ou Carte Mémoire) par session de 2H</a></b><br> 
    <br /> 
    <b><input type="checkbox" name="Montage K7 ancienne" value="79.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/montage.jpg" rel="lightbox"> Montage + DVD (Hi-8, Vidéo 8 ou Digital 8) par session de 2H </a></b><br /> 
    <br /> 
    <a href="../img/diametre_bobines.jpg" rel="lightbox"><img src="../img/encart_produits_tarifs.jpg" alt="" name="" width="469" height="53" border="0"/></a><br /> 
    <b> 
    <input type="checkbox" name="DVD Supplementaire" value="9.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/DVD.jpg" rel="lightbox">DVD Supplémentaire </a></b><br /> 
    <br /> 
    <b> <input type="checkbox" name="Album photo" value="39.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/albumphoto.jpg" rel="lightbox">Album Photos de 20 pages - Grand format </a><br /> 
    </b> 
    <br /> 
    <b><input type="checkbox" name="Clé USB" value="19.00" onclick="this.form.total.value=calculateTotal(this);"><a href="../img/produits_associes/usb.jpg" rel="lightbox"> Film sur clé USB de 2go et mise en ligne sur Viméo </a><br /> 
    </b> <br /> 
    <b><input type="checkbox" name="Tapis de souris" value="19.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/tapis.jpg" rel="lightbox">Tapis de souris personnalisé </a></b><br /> 
    <br /> 
    </td></tr></table> 
    <br /> 
    <b><a href="../img/diametre_bobines.jpg" rel="lightbox"><img src="../img/encart_bobines_tarifs.jpg" alt="" name="" width="469" height="53" border="0"/></a></b> 
    <table><tr><td> 
    <form method="POST" name="selectionForm"> 
    <b><input type="checkbox" name="Taille 1" value="60.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox"> Bobine de taille 1 </a></b><br> 
    <br /> 
    <b><input type="checkbox" name="Taille 2" value="70.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 2 </a></b><br /> 
    <br /> 
    <b><input type="checkbox" name="Taille 3" value="89.90" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 3</a> </b><br /> 
    <br /> 
    <b> <input type="checkbox" name="Taille 4" value="99.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 4</a><br /></b> 
    <br /> 
    <b><input type="checkbox" name="Taille 5" value="132.90" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 5</a><br /> 
    </b> <br /> 
    <b><input type="checkbox" name="Taille 6" value="166.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 6</a></b><br /> 
    <br /> 
    </td></tr></table> 
     
    <br /> 
    <b><a href="../img/diametre_bobines.jpg" rel="lightbox"><img src="../img/encart_bobines_tarifs2.jpg" alt="" name="" width="469" height="53" border="0" /></a></b> 
    <table><tr><td> 
    <form method="POST" name="selectionForm"> 
    <b><input type="checkbox" name="Taille 1" value="60.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 1 </a></b><br> 
    <br /> 
    <b><input type="checkbox" name="Taille 2" value="70.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 2</a></b><br /> 
    <br /> 
    <b><input type="checkbox" name="Taille 3" value="95.90" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 3 </a></b><br /> 
    <br /> 
    <b> <input type="checkbox" name="Taille 4" value="109.00" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 4</a><br /></b> 
    <br /> 
    <b><input type="checkbox" name="Taille 5" value="149.90" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 5</a><br /> 
    </b> <br /> 
    <b><input type="checkbox" name="Taille 6" value="157.90" onclick="this.form.total.value=calculateTotal(this);"> <a href="../img/produits_associes/bobines.jpg" rel="lightbox">Bobine de taille 6</a></b><br /> 
    <br /> 
    </td></tr></table> 
     
    </div> 
    <div><table><tr> 
    <td><p><br> 
    <b>Participation aux frais de livraison via notre prestataire UPS</b><br> 
    <input name="service" type="radio" onclick="this.form.total.value=calculateTotal(this);" value="15.00" checked="CHECKED"> 
    15€ <br> 
    <br> 
     
    <input type="hidden" name="calculatedTotal" value="0"> 
    <input type="hidden" name="previouslySelectedRadioButton" value="0"> 
    <strong>Votre montant total sera:</strong> 
     
    <input type="text" name="total" readonly onfocus="this.blur();" id="total"> 
     
    <strong><br /> 
    <br /> 
    Si vous souhaitez nous faire parvenir ce devis, indiquez votre adresse email et nous vous recontacerons sous 24H.</strong><br /> 
    <form action="formulaire_mailhome.php" method="post" enctype="multipart/form-data" name="monformulaire" target="_blank" id="monformulaire2"> 
    <input name="adressemail" type="text" value="" /> 
    <br /> 
    <input type="submit" value="envoyer" /> 
    </form> 
    <br /> 
    <br /> 
    </p> 
     
     
    <p> 
    </form>

  2. #2
    Expert éminent
    Avatar de Watilin
    Homme Profil pro
    En recherche d'emploi
    Inscrit en
    Juin 2010
    Messages
    3 093
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Ille et Vilaine (Bretagne)

    Informations professionnelles :
    Activité : En recherche d'emploi

    Informations forums :
    Inscription : Juin 2010
    Messages : 3 093
    Points : 6 754
    Points
    6 754
    Par défaut
    Salut,

    Tu as fait du copier-coller ? Ça va pas t’aider à comprendre. Il vaut mieux commencer sur des trucs simples…

    Par exemple essaye de t’envoyer un mail avec une seule donnée. Voici un exemple :
    Code HTML : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <form action="formulaire_mailhome.php" method="post">
      <input type="text" name="la_donnee">
      <input type="submit">
    </form>

    Cet exemple suffit à avoir une idée du fonctionnement des formulaires HTML. D’autre part, tu ne nous as pas donné le code de ton script serveur formulaire_mailhome.php.
    Je te conseille de lire des tutos sur les notions suivantes :
    – les méthodes post et get
    – l’attribut HTML name
    – la fonction mail de PHP

    Et laisse tomber le JavaScript pour l’instant.

    Ce qu’il faut retenir pour l’instant, c’est :
    – une seule balise <form> par page
    – comprendre la relation entre l’attribut name et les données envoyées au serveur.

    J’aimerais voir ton script PHP s’il-te-plaît.

    La FAQ JavaScript – Les cours JavaScript
    Touche F12 = la console → l’outil indispensable pour développer en JavaScript !

  3. #3
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Novembre 2010
    Messages
    2
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2010
    Messages : 2
    Points : 1
    Points
    1
    Par défaut Le voici !
    Merci pour votre aide !

    Code php : 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
    <?php
    $TO = "mon adresse mail";
     
    $h  = "From: Page devis";
     
    $subject = "Nouveau devis disponible";
     
    $message = "Devis";
     
    while (list($key, $val) = each($HTTP_POST_VARS)) {
      $message .= "$key : $val\n";
    }
     
    mail($TO, $subject, $message, $h);
     
    Header("Location: http://www.adresse.fr");
     
    ?>

Discussions similaires

  1. Réponses: 2
    Dernier message: 29/09/2014, 12h01
  2. [PPT-2003] Conserver lien hypertexte pour envoi par mail
    Par zak3r dans le forum Powerpoint
    Réponses: 1
    Dernier message: 09/11/2012, 05h13
  3. [XCode] Déclencher une Copie d'écran pour envoi par mail
    Par macbidule dans le forum XCode
    Réponses: 4
    Dernier message: 08/05/2012, 16h31
  4. [AC-2003] Inserer les codes pour envoi par mail
    Par bomberito dans le forum VBA Access
    Réponses: 1
    Dernier message: 01/02/2012, 21h25
  5. [Upload] upload de fichier pour envoi par mail
    Par mdr_cedrick dans le forum Langage
    Réponses: 2
    Dernier message: 26/05/2009, 08h56

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