comment ajouter un champ
Hors ligneFlexi Le 04/02/2011 à 22:30 Profil de Flexi Configuration de Flexi

bonsoir a tous

j ai trouve ce morceau de code ,mais j ai beau faire travailler ems menages ,je ne vois aps comment ajouter une colone  appellee poids et qui afficherais le poids  en meme temps que le prix  des que l on entre un article

merci de votre aide


function AjouteVirgule(nombre)
{
var AvecVirgule = "";
var num = "" + Math.round(nombre*100);
if (num.length == 0) {AvecVirgule += "0.00";}
else if (num.length == 1) {AvecVirgule += "0.0" + num;}
else if (num.length == 2 && num > 0) {AvecVirgule += "0." + num;}
else if (num.length == 2 && num < 0) {AvecVirgule += "-"+Math.abs(num/100);}
else
{AvecVirgule += num.substring(0, num.length - 2);
AvecVirgule += ".";
AvecVirgule += num.substring(num.length - 2, num.length);}
return AvecVirgule;
}

function Calcule(form)
{
Selection = form.Article1.selectedIndex;
form.NomArticle1.value=form.Article1.options[Selection].text;
PrixArticle=form.Article1.options[Selection].value;
form.Prix1.value=AjouteVirgule(PrixArticle);
Selection = form.Quant1.selectedIndex;
Stotal1 = form.Quant1.options[Selection].value * form.Prix1.value;
form.Montant1.value = AjouteVirgule(Stotal1);

Selection = form.Article2.selectedIndex;
form.NomArticle2.value=form.Article2.options[Selection].text;
PrixArticle=form.Article2.options[Selection].value;
form.Prix2.value=AjouteVirgule(PrixArticle);
Selection = form.Quant2.selectedIndex;
Stotal2 =form.Quant2.options[Selection].value * form.Prix2.value;
form.Montant2.value = AjouteVirgule(Stotal2);



form.Montant1.value = AjouteVirgule(Stotal1);
form.Montant2.value = AjouteVirgule(Stotal2);


Total =(Stotal1+Stotal2);

MontantTVA=Total*(1-1/1.055);
MontantEuro=Total/6.55957;
form.MontantTotal.value = AjouteVirgule(Total);
form.MontantTotalEuro.value = AjouteVirgule(MontantEuro);

form.TVA.value = AjouteVirgule(MontantTVA);
}

function Verifie(form)
{
if ((form.NomArticle1.value != "") && (form.Quant1.value == ""))
{alert('Vous avez entre une Designation sans Quantite (ligne 1)')}

else
if ((form.NomArticle1.value == "") && (form.Quant1.value != ""))
{alert('Vous avez entre une Quantite sans Designation (ligne 1)')}

else

if ((form.NomArticle2.value != "") && (form.Quant2.value == ""))
{alert('Vous avez entre une Designation sans Quantite (ligne 2)')}

else
if ((form.NomArticle2.value == "") && (form.Quant2.value != ""))
{alert('Vous avez entre une Quantite sans Designation (ligne 2)')}




else
{alert('Votre Bon de Commande a ete verifie avec succes')}
}

</SCRIPT>

<META content="Microsoft FrontPage 4.0" name=GENERATOR><BGSOUND src="">
<base target="_self">
</HEAD>
<BODY
background="Bon de commande JAVASCRIPT (Copyright Crash Computing 1998)_fichiers/index.htm"
bgProperties=fixed bgcolor="#008000">
<p align="center"><font color="#000000"><b><u>BON DE COMMANDE</u></b></font></p>
<p align="left">&quot;Les Enfants de Madagascar&quot;<br>
2 rue Carnot (Mairie
de Suresnes)<BR>92150 SURESNES<BR>Tél/fax : 01.47.28.42.77<BR><a href="mailto:madakids@free.fr">Madakids@free.fr</a><BR><BR>
<CENTER>
<FORM>
<TABLE border=3 cellSpacing=3 CELLPADING="0" width="8" height="700">
  <TBODY>
  <TR bgColor=#ffffcc>
    <TH align=middle colSpan=4 bgcolor="#FFFFFF" width="624" height="23">Veuillez entrer vos coordonnees </TH></TR>
  <TR>
    <TD bgcolor="#FFFFFF" width="272" height="24">Nom</TD>
    <TD colSpan=3 bgcolor="#FFFFFF" width="344" height="24"><INPUT name=nom size=34></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" width="272" height="24">Adresse</TD>
    <TD colSpan=3 bgcolor="#FFFFFF" width="344" height="24"><INPUT name=adresse size=34></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" width="272" height="24">Code postal + ville</TD>
    <TD colSpan=3 bgcolor="#FFFFFF" width="344" height="24"><INPUT name=ville size=34></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" width="272" height="24">Pays</TD>
    <TD colSpan=3 bgcolor="#FFFFFF" width="344" height="24"><INPUT name=pays size=34 value=France></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" width="272" height="33">Adresse E-mailou Telephone</TD>
    <TD colSpan=3 bgcolor="#FFFFFF" width="344" height="33"><INPUT name=email size=33 value=@></TD></TR>
  <TR bgColor=#ffffcc>
    <TH align=middle colSpan=4 bgcolor="#FFFFFF" width="624" height="15"><font size="1">Choisissez un article et saisissez une Quantite</font>
    </TH></TR>
  <TR bgColor=#ffffcc>
    <TH bgcolor="#FFFFFF" width="272" height="23">Article</TH>
    <TH bgcolor="#FFFFFF" width="116" height="23">Prix</TH>
    <TH bgcolor="#FFFFFF" width="57" height="23">Qte</TH>
    <TH bgcolor="#FFFFFF" width="155" height="23">Montant</TH></TR><!-- ********** Debut d affichage de la premiere ligne ********* -->
 
 
 
  <TR align=right vAlign=center><TD align=left bgcolor="#FFFFFF" width="272" height="46">1 <SELECT name=Article1 onchange=Calcule(this.form) size="1">
        <OPTION selected value=000></OPTION>
        <OPTION value=150.00>MODELE_001</OPTION>
        <OPTION value=160.00>Masque Sakalava</OPTION>
        <OPTION value=80.00>Voiture</OPTION>
        <OPTION value=100.00>T-shirt de l'association XL</OPTION>
        <OPTION value=70.00>Panneaux de Marqueterie(x2)</OPTION>
        <OPTION value=150.00>Solitaire</OPTION>
        <OPTION value=150.00>Djembe</OPTION>
        <option value="50.00">Cendrier</option>
        <option value="75.00">Girafe en raffia (taille moyenne)</option>
        <option value="150.00">Set de table</option>
              </SELECT> </TD>
     
     
     
    <TD bgcolor=#FFFFFF width="116" height="46"><font size="1">FF</font> <INPUT name=Prix1 onchange=Calcule(this.form)
      size=12> </TD>
     
     
    <TD width="57" height="46" bgcolor="#FFFFFF"><SELECT name=Quant1 onchange=Calcule(this.form)>
       <OPTION selected></OPTION>
        <OPTION value=1>1</OPTION>
        <OPTION value=2>2</OPTION>
        <OPTION value=3>3</OPTION>
        <OPTION value=4>4</OPTION>
        <OPTION value=5>5</OPTION>
        <OPTION value=6>6</OPTION>
        <OPTION value=7>7</OPTION>
        <OPTION value=8>8</OPTION>
        <OPTION value=9>9</OPTION>
        <OPTION value=10>10</OPTION>
        </SELECT> <INPUT name=NomArticle1 type=hidden> </TD>
       
       
       
    <TD bgcolor=#FFFFFF width="155" height="46"><font size="1">FF</font> <INPUT name=Montant1 onchange=Calcule(this.form)
      size=12> </TD></TR>
     
     
     
     
     
     
      <!-- ********** Debut d affichage de la deuxieme ligne ********* -->
  <TR align=right vAlign=center>
    <TD align=left bgcolor="#FFFFFF" width="272" height="46">2 <SELECT name=Article2 onchange=Calcule(this.form) size="1">
        <OPTION selected value=000></OPTION> <OPTION value=150.00>MODELE_001</OPTION> <OPTION value=160.00>Masque
        Sakalava</OPTION> <OPTION
        value=80.00>Voiture</OPTION> <OPTION value=100.00>T-shirt de
        l'association XL</OPTION> <OPTION value=70.00>Panneaux de Marqueterie
        (x2)</OPTION>
        <OPTION value=150.00>Solitaire</OPTION> <OPTION
        value=150.00>Djembe</OPTION>
        <option value="50.00">Cendrier</option>
        <option value="75.00">Girafe en raffia (taille moyenne)</option>
        <option value="150.00">Set de table</option>
      </SELECT> </TD>
    <TD bgcolor=#FFFFFF width="116" height="46"><font size="1">FF</font> <INPUT name=Prix2 onchange=Calcule(this.form)
      size=12> </TD>
    <TD width="57" height="46" bgcolor="#FFFFFF"><SELECT name=Quant2 onchange=Calcule(this.form)> <OPTION
        selected></OPTION> <OPTION value=1>1</OPTION> <OPTION value=2>2</OPTION>
        <OPTION value=3>3</OPTION> <OPTION value=4>4</OPTION> <OPTION
        value=5>5</OPTION> <OPTION value=6>6</OPTION> <OPTION value=7>7</OPTION>
        <OPTION value=8>8</OPTION> <OPTION value=9>9</OPTION> <OPTION
        value=10>10</OPTION></SELECT> <INPUT name=NomArticle2 type=hidden> </TD>
    <TD bgcolor=#FFFFFF width="155" height="46"><font size="1">FF</font> <INPUT name=Montant2 onchange=Calcule(this.form)
      size=12> </TD></TR><!-- ******* Debut d affichage du total ****** -->
  <TR bgColor=#ffffcc>
    <TD align=middle colSpan=3 bgcolor="#FFFFFF" width="461" height="29">Frais de port (France Métropolitaine) :
      <B>Gratuit</B> </TD>
    <TD align=right bgcolor="#FFFFFF" width="155" height="29">0.00 </TD></TR>
  <TR>
    <TD align=middle bgcolor=#FFFFFF colSpan=3 height="1"><B><font size="2">NET A PAYER</font></B> </TD>
    <TD align=right bgcolor=#FFFFFF width="155" height="1"><font size="1">FF</font> <INPUT align=right name=MontantTotal
      onchange=Calcule(this.form) size=12> </TD></TR>
  <TR>
    <TD align=middle colSpan=4 bgcolor="#FFFFFF" width="624" height="27"><INPUT type=reset value=Reset> <INPUT onclick=Calcule(this.form) type=button value=Recalcul> <!-- <INPUT TYPE="button"  VALUE="Vérification"  ONCLICK="Verifie(this.form)">  -->
    </TD></TR>
  <TR>
    <TD align=middle bgcolor=#FFFFFF colSpan=4 width="624" height="50"><font size="1">Pour info, TVA 5,5 % FF
      </font> <INPUT
      name=TVA onchange=Calcule(this.form) size=11>  <font size="1">montant en EUROS
      </font><INPUT
      name=MontantTotalEuro onchange=Calcule(this.form) size=12>
</TD></TR></TBODY></TABLE></FORM></CENTER>
<H6><font color="#FFFFFF">Cette page n'envoie aucune information électronique. Elle vous permet
uniquement d'imprimer le bon de commande.</font></H6>
<H5 align="center">
</H5>
<p align="center">&nbsp;</p></BODY></HTML>

Vous avez résolu votre problème avec VIC ? Faites-le savoir sur les réseaux sociaux !
Vulgarisation-informatique.com
Cours en informatique & tutoriels