Ver Mensaje Individual
  #3 (permalink)  
Antiguo 12/06/2009, 16:31
mulata
 
Fecha de Ingreso: junio-2009
Mensajes: 7
Antigüedad: 15 años, 9 meses
Puntos: 0
Respuesta: Como realizar varios calculos en una factura consecutiva

hola gracias por responder si tengo la aplicacion pero no tengo expriencia en este foro, disculpame, aki esta el codigo ojala me puedas ayudar el algo.
<html>
<head>
<title> Producto</title>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">

</style>
</head>


<body>




<form id="myform" name="myform" method="post" action="<?php echo$_SERVER['PHP_SELF'];?>">
<p align="center">
<input type="hidden" name="hiddenNeto" value="0">
</p>
<p align="center" class="Estilo3 Estilo24 Estilo6 Estilo15" font-family:"Gill Sans Ultra Bold"><span class="Estilo18">Factura</span>
<script language="javaScript1.2">
var isNS4 = (navigator.appName=="Netscape")?1:0;
</script>
</p>
<p align="center" class="Estilo26">Producto</p>
<thead>
<table width="645" >
<tr>
<th class="Estilo14">C&oacute;digo</th>
<th><span class="Estilo14">Marca </span></th>
<th class="Estilo14"> Precio </th>

<th class="Estilo14">Cant</th>


</tr>
</table>
</thead>


<table id="bloque" style="float:down">
<tr>
<td><input type="text" name="txtcodigo" class="link_red_bold" size="30" id="txtcodigo" onKeyPress="producto.VerificarTecla3(event); "></td>

<td><input type="text" name="txtmarca" id="txtmarca" class="link_red_bold" size="15" /></td>

<td><input type="text" name="txtprecio" id="txtprecio" class="link_red_bold" size="15" onkeyup="addHiddenNeto(this.value)" onfocus="setHiddenNeto(this.value);"/></td>
<td><input type="text" name="txtcantidad" id="txtcantidad" size="15" class="link_red_bold"/></td>

<td><input name="button" type="button" onClick="borrar()">borrar</td>
</tr>
</table>
</form>
<div style="clear:both; padding-top:15px">agregar<button onClick="doIt()"></button>
</div>
<table width="340" border="1" align="center" bordercolor="#85878C" bgcolor="#FFCC66">


<tr>
<td width="106"><p class="Estilo21">iva12%
<input name="txtiva" type="text" class="link_red_bold" id="txtiva" size="15"/>
</p></td>



<td width="106"><span class="Estilo21">Subtotal
<input name="txtsubtotal" type="text" class="link_red_bold" id="txtsubtotal" size="15"/>
</span></td>
<td width="106"><span class="Estilo21">Total
<input name="txttotal" type="text" class="link_red_bold" id="txttotal" size="15"/>
</span></td>
</table>
</div>
<blockquote>
<p align="center">&nbsp;</p>
</blockquote>
</body>
</html>


<script>
function doIt()
{
var f = document.getElementById('myform');
var b = document.getElementById('bloque');

var b2=b.cloneNode(true)
Get('txtmarca').value="";
Get('txtcodigo').value="";
Get('txtprecio').value="";
Get('txtcantidad').value="";

f.appendChild(b2);
}



function borrar()
{


var f = document.getElementById('myform');
var b = document.getElementById('bloque');

f.removeChild(b);




}



function addHiddenNeto(n){
if(n==""){n=0;}
document.getElementById('txtsubtotal').value = document.getElementById('txtsubtotal').value-document.myform.hiddenNeto.value;
document.myform.hiddenNeto.value = n;
document.getElementById('txtsubtotal').value = roundNumber(eval(parseFloat(document.getElementByI d('txtsubtotal').value)+parseFloat(document.myform .hiddenNeto.value)),2);
setNeto();
}
function setHiddenNeto(n){
if(n==""){n=0;}
document.myform.hiddenNeto.value = n;
setNeto();
}

function setNeto(){

document.getElementById('txtiva').value = roundNumber((parseFloat(0.12) * parseFloat(document.getElementById('txtsubtotal'). value)),2);
document.getElementById('txttotal').value = roundNumber(parseFloat(document.getElementById('tx tsubtotal').value)+(parseFloat(0.12) * parseFloat(document.getElementById('txtsubtotal'). value)),2);

}

function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
return Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
}


</script>

si podras observar hace el calculo del iva , subtotal y total solo con el producto pero yo quiero que lo haga para varios productos y que se pueda calcular precio por cantidad. ojala me puedan ayudar xfa. GRACIAS