Forum de discussion
Forum « Programmation Javascript » (archives)
Probleme avec mon bon de commane
Envoyé: 24 avril 2004, 5h06 par ElCamillo
Le voila:
<SCRIPT LANGUAGE="javascript">
var validmodcommand=0;
function Envoyer(f)
{
msgalert = "vous n'avez pas transmis les données suivantes: "
var error = 0;
if (!document.form.nom.value)
{msgalert = msgalert + " votre nom,";
error = 1;
}
if (!document.form.adresse.value)
{msgalert = msgalert + " votre adresse,";
error = 1;
}
if (!document.form.ville.value)
{msgalert = msgalert + " votre ville,";
error = 1;
}
if (!document.form.codepostal.value)
{msgalert = msgalert + " votre code postal,";
error = 1;
}
if (document.form.confirmation.selectedIndex == 0)
{if (!document.form.email.value)
{if (error == 1) msgalert = msgalert + " de plus";
msgalert = msgalert + " vous n'avez pas transmis d'adresse e-mail alors que vous souhaitez une confirmation par mail";
error = 1;}}
if (document.form.confirmation.selectedIndex == 1)
{if (!document.form.tel.value)
{if (error == 1) msgalert = msgalert + " de plus";
msgalert = msgalert + " vous n'avez pas transmis de numéro de téléphone alors que vous souhaitez une confirmation par téléphone";
error = 1;}}
if (document.form.confirmation.selectedIndex == 2)
{if (!document.form.fax.value)
{if (error == 1) msgalert = msgalert + " de plus";
msgalert = msgalert + " vous n'avez pas transmis de numero de fax alors que vous souhaitez une confirmation par fax";
error = 1;}}
if (error == 1)
{
alert((msgalert + ". Veuillez remplir les champs correspondant afin que votre commande vous parvienne."));
}
else
{
f.submit();
alert("votre commande va être envoyée, vous recevrez un mail de confirmation dés que j'aurais consulté votre commande");
}
}
function actualise(form)
{
var qt1 = document.form.qtpategeni125.value;
var qtXpoid1 = qt1 * 165;
document.form.qtXpoidpategeni125.value = qtXpoid1;
var qt2 = document.form.qtpategeni200.value;
var qtXpoid2 = qt2 * 255;
document.form.qtXpoidpategeni200.value = qtXpoid2;
var qt3 = document.form.qtpatehure.value;
var qtXpoid3 = qt3 * 510;
document.form.qtXpoidpatehure.value = qtXpoid3;
var qt4 = document.form.qtrillette.value;
var qtXpoid4 = qt4 * 255;
document.form.qtXpoidrillette.value = qtXpoid4;
var qt5 = document.form.qtcivet420.value;
var qtXpoid5 = qt5 * 515;
document.form.qtXpoidcivet420.value = qtXpoid5;
var qt6 = document.form.qtcivet840.value;
var qtXpoid6 = qt6 * 1000;
document.form.qtXpoidcivet840.value = qtXpoid6;
var qt7 = document.form.qtcivet750.value;
var qtXpoid7 = qt7 * 1225;
document.form.qtXpoidcivet750.value = qtXpoid7;
document.form.prixtpategeni125.value = qt1 * 28;
var prixt1 = document.form.prixtpategeni125.value;
document.form.prixtpategeni200.value = qt2 * 42;
var prixt2 = document.form.prixtpategeni200.value;
document.form.prixtpatehure.value = qt3 * 42;
var prixt3 = document.form.prixtpatehure.value;
document.form.prixtrillette.value = qt4 * 42;
var prixt4 = document.form.prixtrillette.value;
document.form.prixtcivet420.value = qt5 * 63;
var prixt5 = document.form.prixtcivet420.value;
document.form.prixtcivet840.value = qt6 * 126;
var prixt6 = document.form.prixtcivet840.value;
document.form.prixtcivet750.value = qt7 * 92;
var prixt7 = document.form.prixtcivet750.value;
var prixt;
prixt = parseInt(prixt1) + parseInt(prixt2) + parseInt(prixt3) + parseInt(prixt4)+ parseInt(prixt5)+ parseInt(prixt6)+ parseInt(prixt7);
document.form.prixt.value = prixt;
var qtt;
qtt = parseInt(qtXpoid1) + parseInt(qtXpoid2) + parseInt(qtXpoid3)+ parseInt(qtXpoid4)+ parseInt(qtXpoid5)+ parseInt(qtXpoid6)+ parseInt(qtXpoid7);
document.form.qtt.value = qtt;
var fraisdexp;
if (qtt <= 30000) fraisdexp = 101;
if (qtt <= 15000) fraisdexp = 71;
if (qtt <= 10000) fraisdexp = 61;
if (qtt <= 7000) fraisdexp = 48.5;
if (qtt <= 5000) fraisdexp = 42;
if (qtt <= 3000) fraisdexp = 35;
if (qtt <= 2000) fraisdexp = 30;
if (qtt <= 1000) fraisdexp = 26.5;
if (qtt <= 500) fraisdexp = 21;
if (qtt <= 250) fraisdexp = 14.5;
document.form.fraisdexp.value = fraisdexp;
var total = parseInt(prixt) + parseInt(fraisdexp);
document.form.total.value = total;
}
function valid()
{
validmodcommand = 1;
}
</script>
Ainsi que le formulaire qui correspond:
<FORM action= "mailto:eric@darley.com.fr?subject=commande" name="form" METHOD=POST ENCTYPE="text/plain">
<table width="101%" border="1" cellspacing="1" cellpadding="0" height="373">
<tr>
<td width="27%" height="14">
<div align="center"><b>Nom</b></div>
</td>
<td width="10%" height="14">
<p align="center"><b>poid net</b> </p>
</td>
<td width="9%" height="14">
<p align="center"><b>poid<br>
</b><b>brut</b></p>
</td>
<td width="15%" height="14">
<div align="center"><b>Prix unitaire</b></div>
</td>
<td width="13%" height="14">
<div align="center"><b>Quantité</b></div>
</td>
<td width="11%" height="14" valign="middle">
<div align="center">
<p><b>total<br>
</b><b>poid</b></p>
</div>
</td>
<td width="15%" height="14">
<div align="center"><b>Prix </b></div>
</td>
</tr>
<tr>
<td width="27%" height="16">Paté pur sanglier genievre
</td>
<td width="10%" height="16">
<div align="center">125 gr</div>
</td>
<td width="9%" height="16">165gr</td>
<td width="15%" height="16">
<div align="center">28 Fr</div>
</td>
<td width="13%" height="16">
<div align="center">
<input type="text" name="qtpategeni125" size="3">
</div>
</td>
<td width="11%" height="16">
<div align="center">
<input type="text" name="qtXpoidpategeni125" size="4">
gr </div>
</td>
<td width="15%" height="16">
<div align="center">
<input type="text" name="prixtpategeni125" size="4">
FF </div>
</td>
</tr>
<tr>
<td width="27%">Paté pur sanglier genievre</td>
<td width="10%">
<div align="center">200 gr</div>
</td>
<td width="9%">255gr</td>
<td width="15%">
<div align="center">42 Fr</div>
</td>
<td width="13%">
<div align="center">
<input type="text" name="qtpategeni200" size="3">
</div>
</td>
<td width="11%">
<div align="center">
<input type="text" name="qtXpoidpategeni200" size="4">
gr</div>
</td>
<td width="15%">
<div align="center">
<input type="text" name="prixtpategeni200" size="4">
FF</div>
</td>
</tr>
<tr>
<td width="27%">Paté de hure pur sanglier(bocal)</td>
<td width="10%">
<div align="center">200 gr</div>
</td>
<td width="9%">510gr</td>
<td width="15%">
<div align="center">42 Fr</div>
</td>
<td width="13%">
<div align="center">
<input type="text" name="qtpatehure" size="3">
</div>
</td>
<td width="11%">
<div align="center">
<input type="text" name="qtXpoidpatehure" size="4">
gr </div>
</td>
<td width="15%">
<div align="center">
<input type="text" name="prixtpatehure" size="4">
FF</div>
</td>
</tr>
<tr>
<td width="27%">Rillettes pur sanglier</td>
<td width="10%">
<div align="center">200 gr</div>
</td>
<td width="9%">255gr</td>
<td width="15%">
<div align="center">42 Fr</div>
</td>
<td width="13%">
<div align="center">
<input type="text" name="qtrillette" size="3">
</div>
</td>
<td width="11%">
<div align="center">
<input type="text" name="qtXpoidrillette" size="4">
gr </div>
</td>
<td width="15%">
<div align="center">
<input type="text" name="prixtrillette" size="4">
FF </div>
</td>
</tr>
<tr>
<td width="27%">Civet au madiran et champignons</td>
<td width="10%">
<div align="center">420 gr</div>
</td>
<td width="9%">515gr</td>
<td width="15%">
<div align="center">63 Fr</div>
</td>
<td width="13%">
<div align="center">
<input type="text" name="qtcivet420" size="3">
</div>
</td>
<td width="11%">
<div align="center">
<input type="text" name="qtXpoidcivet420" size="4">
gr </div>
</td>
<td width="15%">
<div align="center">
<input type="text" name="prixtcivet420" size="4">
FF </div>
</td>
</tr>
<tr>
<td width="27%">Civet au madiran et champignons</td>
<td width="10%">
<div align="center">840 gr</div>
</td>
<td width="9%"> </td>
<td width="15%">
<div align="center">126 Fr</div>
</td>
<td width="13%">
<div align="center">
<input type="text" name="qtcivet840" size="3">
</div>
</td>
<td width="11%">
<div align="center">
<input type="text" name="qtXpoidcivet840" size="4">
gr </div>
</td>
<td width="15%">
<div align="center">
<input type="text" name="prixtcivet840" size="4">
FF </div>
</td>
</tr>
<tr>
<td width="27%" height="42">Civet au madiran et champignons
prêt à mijoter(bocal)</td>
<td width="10%" height="42">
<div align="center">750 gr</div>
</td>
<td width="9%" height="42">1225gr</td>
<td width="15%" height="42">
<div align="center">92 Fr</div>
</td>
<td width="13%" height="42">
<div align="center">
<input type="text" name="qtcivet750" size="3">
</div>
</td>
<td width="11%" height="42">
<div align="center">
<input type="text" name="qtXpoidcivet750" size="4">
gr </div>
</td>
<td width="15%" height="42">
<div align="center">
<input type="text" name="prixtcivet750" size="4">
FF </div>
</td>
</tr>
<tr>
<td width="27%" height="37">Saucisse sèche pur sanglier</td>
<td width="10%" height="37" align="center">~200 gr</td>
<td width="9%" height="37"> </td>
<td width="15%" height="37">
<div align="center">22 Fr/100g</div>
</td>
<td width="39%" height="111" colspan="3" rowspan="2">
<div align="center"><font size="2">Les commandes pour ces
produits (saucisse et jambon) sont à effectuer par
mail, fax, lettre ou téléphone et necessite
un délai de 3 mois</font></div>
<div align="center"> </div>
<div align="center"></div>
<div align="center"> </div>
<div align="center"> </div>
<div align="center"> </div>
</td>
</tr>
<tr>
<td width="27%" height="37">Jambon sec pur sanglier</td>
<td width="10%" height="37" align="center">
<p>tranché<br>
~100gr</p>
</td>
<td width="9%" height="37"> </td>
<td width="15%" height="37">
<div align="center">36 Fr/100g</div>
</td>
</tr>
<tr>
<td height="44" colspan="6">
<div align="center"><b>TOTAL</b></div>
</td>
<td width="15%" height="44" align="center">
<div align="center">
<input type="text" name="prixt" size="4">
FF </div>
</td>
</tr>
<tr>
<td height="37" colspan="5">
<div align="right"><b> Total poid, Frais d'expeditions</b></div>
</td>
<td height="37" width="11%">
<div align="center">
<input type="text" name="qtt" size="5">
gr</div>
</td>
<td width="15%" height="37" align="center">
<div align="center">
<input type="text" name="fraisdexp" size="4">
FF</div>
</td>
</tr>
<tr>
<td height="37" colspan="6">
<div align="right"><b> TOTAL Réglement</b> </div>
</td>
<td width="15%" height="37" align="center">
<div align="center">
<input type="text" name="total" size="5">
FF </div>
</td>
</tr>
</table>
<p>
<input type="button" name="actualiser" value="Faire le calcul" onClick="actualise(form)">
<input type="button" name="imprimer" value="Imprimer" onClick="window.print()">
</p>
<p><b>Informations personnelles:</b></p>
<table width="109%" border="0">
<tr>
<td width="49%">Nom<font color="#FF0000">*</font> :
<input type="text" name="nom">
</td>
<td width="51%">Prenom :
<input type="text" name="prenom">
</td>
</tr>
<tr>
<td width="49%">E-mail** :
<input type="text" name="email">
</td>
<td width="51%">Adresse<font color="#FF0000">* </font>:
<input type="text" name="adresse">
</td>
</tr>
<tr>
<td width="49%">Ville<font color="#FF0000">* </font>:
<input type="text" name="ville">
</td>
<td width="51%">Code postal<font color="#FF0000">* </font>:
<input type="text" name="codepostal">
</td>
</tr>
<tr>
<td width="49%" height="35">Telephone** :
<input type="text" name="tel">
</td>
<td width="51%" height="35">
<p>Fax** :
<input type="text" name="fax">
</p>
</td>
</tr>
<tr>
<td width="49%" height="35">
<p>voulez-vous une confirmation de la commande<font color="#000000">
par </font><font color="#FF0000">* </font>:
<select name="confirmation" size="1">
<option selected>mail</option>
<option>téléphone</option>
<option>fax</option>
<option>lettre</option>
</select>
<br>
</p>
</td>
<td width="51%" height="35">
<p> </p>
</td>
</tr>
</table>
<p><font color="#FF0000">*</font> : ces champs sont obligatoires<br>
** : ces champs sont soit facultatifs, soit obligatoires suivant
le type de confirmtion dont vous souhaitez.</p>
<p>
<input type="button" value="Envoyer" onClick="Envoyer(this.form)" name="button">
</p>
</form>
Réponses
|