Tema: sumar
Ver Mensaje Individual
  #8 (permalink)  
Antiguo 25/02/2008, 17:56
niltza
 
Fecha de Ingreso: agosto-2004
Mensajes: 440
Antigüedad: 19 años, 8 meses
Puntos: 2
Re: sumar

oye ya hice lo que me dijiste perfeco pero ahora cuando envio los datos a la base de datos no me esta cogiendo esos datos aqui esta mi codigo

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Factura::Imprimir</title>

<script type="text/javascript">
function sumar(frm) {
cv = frm.cantidad.value;
vu = frm.valoru.value;
iv = frm.iva.value;
vt = frm.total.value;

if (cv=='' || isNaN(cv)) cv = 0;
if (vu=='' || isNaN(vu))vu = 0;
if (iv=='' || isNaN(iv))iv = 0;
if (vt=='' || isNaN(vt))vt = 0;

frm.total.value =parseFloat(cv) * parseFloat(vu);
frm.subtotal.value=frm.total.value;
frm.iva.value =parseFloat(frm.total.value) * 0.16;
frm.valortotal.value =parseFloat(frm.iva.value) + parseFloat(frm.subtotal.value);
}
</script>
<head>

<body>

<form action="imprimefactura.php" method="post" >
  <div id="descripcion">
  <table width="100%" height="204" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
    <tr>
      <td width="49%" height="33"><div align="center"><span class="Estilo12">DESCRIPCION</span></div></td>
      <td width="18%"><div align="center"><span class="Estilo12">VALOR UNITARIO </span></div></td>
      <td width="16%"><div align="center" class="Estilo12">CANTIDAD</div></td>
      <td width="17%"><div align="center" class="Estilo12">TOTAL</div></td>
    </tr>
    <tr>
      <td height="98"><textarea name="descripcion" cols="40" rows="5"></textarea></td>
      <td height="98"><div align="center">
        <input name="valoru" type="text" id="valoru" size="15" onkeypress= "return acceptNum(event)" onkeyup = "sumar(this.form)"/>
      </div></td>
      <td height="98"><div align="center">
        <input name="cantidad" type="text" id="cantidad" size="15" onkeypress= "return acceptNum(event)" onkeyup = "sumar(this.form)"/>
      </div></td>
      <td height="98"><div align="center">
        <input name="total" type="text" id="total" size="15"  disabled="disabled" />
      </div></td>
    </tr>
    <tr>
      <td colspan="2" rowspan="3" valign="top"><span class="Estilo12">VALOR EN LETRAS </span><br />
          <br />
          <input name="letras" type="text" id="letras" size="80" /> </td>
      <td height="24"><div align="center" class="Estilo12">SUBTOTAL</div></td>
      <td height="24"><div align="center">
        <input name="subtotal" type="text" id="subtotal" size="15" disabled="disabled"/>
      </div></td>
    </tr>
    <tr>
      <td height="24"><div align="center" class="Estilo12">IVA</div></td>
      <td height="24"><div align="center">
        <input name="iva" type="text" id="iva" size="15" disabled="disabled" onkeyup = "sumar(this.form)"/>
      </div></td>
    </tr>
    <tr>
      <td height="23"><div align="center"><span class="Estilo12">VALOR TOTAL </span></div></td>
      <td height="23"><div align="center">
        <input name="valortotal" type="text" id="valortotal" size="15" disabled="disabled" onkeyup = "sumar(this.form)"/>
      </div></td>
    </tr>
  </table>
</div>
<table width="927" height="611" border="0" align="left">
  <tr>
    <td width="917" height="607">&nbsp;</td>
  </tr>
</table>
<div id="Layer3">
  <div align="center"><span class="Estilo8">
    <input name="enviar" type="button" id="enviar" onclick="validar(this.form)" value="Enviar"/>
    <input name="borrar" type="reset" id="borrar" value="Borrar"/>
  </span></div>
</div>
</form>
</body> 
estoy recibiendo los valores

$valoru=$_POST["valoru"];
$cantidad=$_POST["cantidad"];
$total=$_POST["total"];
$subtotal=$_POST["subtotal"];
$iva=$_POST["iva"];
$valortotal=$_POST["valortotal"];
__________________
paty :adios:

Última edición por niltza; 25/02/2008 a las 18:09