Ver Mensaje Individual
  #6 (permalink)  
Antiguo 20/10/2009, 07:04
4sc1r
 
Fecha de Ingreso: abril-2003
Mensajes: 201
Antigüedad: 21 años, 9 meses
Puntos: 0
Respuesta: Multiplicar campos

Cita:
Iniciado por bjorkboy Ver Mensaje
y pq no publicaste la solucion??'
Al final lo hice con js, http://webdeveloper.earthweb.com/web...php/431_viewit
Código HTML:
<!-- This script has been in the http://www.javascripts.com Javascript Public Library! -->
<!-- Note that though this material may have been in a public depository, certain author copyright restrictions may apply. -->
<HTML><HEAD><TITLE>got a quantity? Price? This gives the total.</TITLE>
<SCRIPT>

function dp(price) 
{
   string = "" + price;
   number = string.length - string.indexOf('.');
   if (string.indexOf('.') == -1)
      return string + '.00';
   if (number == 1)
      return string + '00';
   if (number == 2)
      return string + '0';
   if (number > 3)
      return string.substring(0,string.length-number+3);
return string;
}

function calculate()
{
document.calcform.total1.value = dp((document.calcform.price1.value)*(document.calcform.quantity1.value))
document.calcform.total2.value = dp((document.calcform.price2.value)*(document.calcform.quantity2.value))
document.calcform.total3.value = dp((document.calcform.price3.value)*(document.calcform.quantity3.value))
document.calcform.subtotal.value = dp(eval(document.calcform.total1.value) + eval(document.calcform.total2.value) + eval(document.calcform.total3.value))
document.calcform.tax.value = dp((document.calcform.subtotal.value)*0.175)
document.calcform.total.value = dp((document.calcform.subtotal.value)*1.175)
}

</SCRIPT>
</HEAD><BODY bgcolor="#ffffff" onload="calculate"><CENTER>

<FORM name="calcform" action="mailto:[email protected]" method="post">

<TABLE cellpadding=2 border=2 cellspacing=2><TR><TD>QUANTITY</TD><TD>PRICE</TD><TD>TOTAL</TD></TR>

<TR>
<TD><INPUT type="text" name="quantity1" ONCHANGE="calculate()"></TD>
<TD><INPUT type="text" name="price1" ONCHANGE="calculate()"></TD>
<TD><INPUT type="text" name="total1"></TD>
</TR>

<TR>
<TD><INPUT type="text" name="quantity2" ONCHANGE="calculate()"></TD>
<TD><INPUT type="text" name="price2" ONCHANGE="calculate()"></TD>
<TD><INPUT type="text" name="total2"></TD>
</TR>

<TR>
<TD><INPUT type="text" name="quantity3" ONCHANGE="calculate()"></TD>
<TD><INPUT type="text" name="price3" ONCHANGE="calculate()"></TD>
<TD><INPUT type="text" name="total3"></TD>
</TR>
<TR><TD></TD><TD>SUBTOTAL</TD><TD><INPUT type="text" name="subtotal"></TD></TR>
<TR><TD></TD><TD>TAX - 17.5%</TD><TD><INPUT type="text" name="tax"></TD></TR>
<TR><TD></TD><TD>GRAND TOTALL</TD><TD><INPUT type="text" name="total"></TD></TR>
</TABLE><INPUT type="button" Value="PRESS FIRST to calculate the values" ONCLICK="calculate()"><BR><INPUT type="submit" Value="Then click this to SUBMIT"><BR>If ya liked this javescript, ask me for <A HREF="mailto:[email protected]">MORE!!</A>
<BR><BR>JMF says BOO!!</FORM>

</BODY></HTML>
<!-- Tommy Raven (Min) says Moo. -->