Ben oui, j'ai fait des tests et re-tests.. je ne suis pas sûre de mettre au bon endroit :
- les déclarations de tableau array=(),
- le code de calcul, doit être le processus, mais ds mon formulaire de confirmation de cde, je dois renvoyer les variables $résultat (...)
- je viens de réintégrer la vérif javascript sur les checkboox : et il m'empoisonne car il bloque tout dans le processus.
Ci-joint respectivement les codes javascript (extrait) et php (intégralement)
function Verif()
{
if (document.insc.nom.value=="")
{
alert('Veuillez indiquer votre nom');
document.insc.nom.focus();
}
else if (document.insc.prenom.value=="")
{
alert('Veuillez indiquer votre prénom');
document.insc.prenom.focus();
}
else if(document.insc.tel.value=="")
{
alert("Veuillez indiquer votre téléphone");
document.insc.tel.focus();
}
else if(document.insc.email.value=="")
{
alert("Veuillez entrer une adresse email\n");
document.insc.email.focus();
}
else if(((document.insc.email.value!='') && (!isMail(document.insc.email.value))))
{
alert("Votre adresse email ne semble pas correctement saisie\n Vérifiez que vous n'avez pas oublié le signe @ par exemple");
document.insc.email.focus();
}
else if (document.insc.adresse.value=="")
{
alert('Veuillez indiquer votre adresse');
document.insc.adresse.focus();
}
else if (document.insc.ville.value=="")
{
alert('Veuillez indiquer votre Code Postal et votre Ville');
document.insc.ville.focus();
}
else if((document.insc.checkbox[].checked)&&(document.insc.checkbox[0].checked))
{
alert('Veuillez préciser vos choix de pack(s) "Au Fil des Mois" ')
}
else
{
alert('votre commande va être envoyée - merci d\'attendre la confirmation')
document.insc.submit();
}
}
ci-dessus le code php :
<?php
$packs_ids = array('pack1','pack2','pack3','pack4','pack5','pack6');
$packs_libelles = array('-Pack 1 Sélection ROUGES 13 coupons 15x55cms','-Pack 2 Sélection ECRUS 11 coupons 15x55 cms','-Pack 3 Sélection BRUNS 7 coupons 15x110cms','-Pack 4 Sélection BLEUS 11 coupons 15x55cms','-Pack 5 Sélection VIOLETS 5 coupons 15x110cms','-Pack 6 Sélection VERTS 11 coupons 15x55 cms');
$packs_montants = array(17, 14, 18, 14, 13, 15);
$formulaire=$_POST['formulaire'];
if ($formulaire==""){
print("
<form action='#' method='post' name='insc'>
<table width='600' border='0'>
<tr>
<td colspan='2' align='center'> <img src='logo_form.jpg' alt='logo'> </td>
</tr>
<tr>
<td colspan='2'><div class='rubrique'>VOS COORDONNEES :</div></td>
</tr>
<tr>
<td width='290'><div class='form'> NOM * :</div></td>
<td width='300' align='right'><input name='nom' class='inputname'type='text' size='48'maxlength='48' > </td>
</tr>
<tr>
<td width='290'><div class='form'>PRENOM *:</div></td>
<td width='300' align='right'><input name='prenom' class='inputname' type='text' size='48'maxlength='48'></td>
</tr>
<tr>
<td width='290'><div class='form'>TEL (mobile/fixe) *: </div> </td>
<td width='300'align='right'> <input name='tel' class='inputname' type='text' size='48' maxlength='48'> </td>
</tr>
<tr>
<td width='290'><div class='form'>E-MAIL *: </div></td>
<td width='300' align='right'> <input name='email' class='inputname' type='text' size='48' maxlength='48'></td>
</tr>
<tr>
<td width='290'> <div class='form'>ADRESSE COMPLETE D'EXPEDITION <b>*</b>:</div></td>
<td width='300' align='right'><input name='adresse' class='inputname' type='text' size='48' maxlength='48'></td>
</tr>
<tr>
<td width='290'><div class='form'>CP et VILLE <b>*</b>:</div></td>
<td width='300' align='right'><input name='ville' class='inputname'type='text' size='48' maxlength='48'></td>
</tr>
<tr>
<td colspan='2 align='right'> <div class='champ'>* : informations indispensables</div></td>
</tr>
<tr>
<td colspan='2'><div class='nota'>Les commandes <u>HORS FRANCE</u> : Svp nous contacter directement par mail : postmaster@filalapat.fr<br></div></td>
</tr>
<tr>
<td colspan='2'><div class='rubrique'><br>SELECTIONNEZ VOS PACKS :</div></td>
</tr>
<tr>
<td colspan='2'>
<table border='0' width='580' bgcolor='#FFEBB6' cellspacing='0' cellpadding='0'>
<tr>
<td width='380' bgcolor='#FFEBB6' align='left'> <div class='form'><b>-PACK 1 Sélection Rouges 17,55 euros </b>(13 coupons 15x55 cms)</div></td>
<td width='200' bgcolor='#FFEBB6' align='right'> <input type='checkbox' name='checkbox[1]' value='1'> </td>
</tr>
<tr>
<td width='380' bgcolor='#FFEBB6' align='left'><div class='form'><b>-PACK 2 Sélection Ecrus 14,85 euros </b>(11 coupons 15x55 cms)</div></td>
<td width='200' bgcolor='#FFEBB6' align='right'><input type='checkbox' name='checkbox[2]' value='2'> </td>
</tr>
<tr>
<td width='380' bgcolor='#FFEBB6' align='left'><div class='form'><b>-PACK 3 Sélection Bruns 18,90 euros</b> (7 coupons 15x110 cms)</div></td>
<td width='200' bgcolor='#FFEBB6' align='right'><input type='checkbox' name='checkbox[3]' value='3'> </td>
</tr>
<tr>
<td width='380' bgcolor='#FFEBB6' align='left'><div class='form'><b>-PACK 4 Sélection Bleus 14,85 euros </b>(11 coupons 15x55 cms)</div></td>
<td width='200' bgcolor='#FFEBB6' align='right'><input type='checkbox' name='checkbox[4]' value='4'> </td>
</tr>
<tr>
<td width='380' bgcolor='#FFEBB6' align='left'><div class='form'><b>-PACK 5 Sélection Violets 13,50 euros </b>(5 coupons 15x110 cms)</div></td>
<td width='200' bgcolor='#FFEBB6' align='right'><input type='checkbox' name='checkbox[5]' value='5'> </td>
</tr>
<tr>
<td width='380' bgcolor='#FFEBB6' align='left'><div class='form'><b>-PACK 6 Sélection Verts 14,85 euros </b>(11 coupons 15x55 cms)</div></td>
<td width='200' bgcolor='#FFEBB6' align='right'><input type='checkbox' name='checkbox[6]' value='6'> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan='2'><div class='nota'>+ Frais de port unique : 5 euros Colissimo Suivi<br></div></td>
</tr>
<tr>
<td colspan='2' height='30' ><div class='adresse'><br> xxxxxxxxxxxxx- xxxxxxxxxx
</div></td>
</tr>
</table>
<div align='center'>
<input type='reset' value='EFFACER' class='input' name='reset'>
<input type='hidden' value='send' name='formulaire'>
<input type='button' value='ENVOYER' class='input' name='valider' onclick='javascript:Verif();'>
</div>
</form>
<p>
<a href='http://validator.w3.org/check?uri=referer'><img src='http://www.w3.org/Icons/valid-html401' alt='Valid HTML 4.01 Transitional' height='20' width='77'></a>
<a href='http://validator.w3.org/check?uri=referer'><img src='http://www.w3.org/Icons/valid-html401-blue' alt='Valid HTML 4.01 Transitional' height='20' width='77'></a>
<a href='http://jigsaw.w3.org/css-validator/check/referer'><img style='border:0;width:77px;height:20px'src='http://jigsaw.w3.org/css-validator/images/vcss' alt='CSS Valide !'\ ></a>
</p>
");
}// fin du if fomulaire vide
/***********************************************1ER ELSE OUVERTURE */
else{
$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$tel=$_POST['tel'];
$email=$_POST['email'];
$adresse=$_POST['adresse'];
$ville=$_POST['ville'];
$packs_ids=$_POST['checkbox'];
$nom=htmlspecialchars($nom);
$prenom=htmlspecialchars($prenom);
$mail=htmlspecialchars($mail);
$adresse=htmlspecialchars($adresse);
$ville=htmlspecialchars($ville);
$message="";
if($_SERVER('REQUEST_METHOD')=='POST') {if(!empty($_POST['checkbox'])) {
$montant_total = 0;
foreach($_POST['checkbox'] as $checkbox) {
echo 'Pack choisi : '.$packsids[$checkbox].' / montant : '.$packsmontants[$checkbox].'euros';
$montanttotal += $packsmontants[$checkbox];
}
echo 'Montant Total : '.$montanttotal.'euros';
}
}
Merci !!!!!
Modifié par bouzette (21 Nov 2009 - 19:24)