Para tí una pavada, y no sabes el aventón que me has dado.
Y que se te ocurre para cuando la variable es más de 1. Es decir tanto E, como otras variables deben funcionar de igual manera.
Cita: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin título</title>
<script>
function ingresoneto(){
var A = document.getElementById('IB').value;
var B = document.getElementById('GC').value;
var D = document.getElementById('IN');
D.value = ((parseFloat(A) - parseFloat(B)));}
function margenbruto(){
var D = document.getElementById('IN').value;
var E = document.getElementById('CD').value;
var F = document.getElementById('MB');
F.value = ((parseFloat(D) - parseFloat(E)))
}
function resultadooperativo(){
var F = document.getElementById('MB').value;
var G = document.getElementById('GA').value;
var H = document.getElementById('GE').value;
var I = document.getElementById('RO');
I.value = ((parseFloat(F) - parseFloat(G) - parseFloat(H)))
}
function resultadoporproduccion(){
var I = document.getElementById('RO').value;
var J = document.getElementById('AI').value;
var K = document.getElementById('RPP');
K.value = ((parseFloat(I) - parseFloat(J)))
}
</script>
</head>
<body>
<form>
<p align="center">
Ingreso Bruto ($):
<input type="number" id="IB" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
Gastos de Comercialización ($):
<input type="number" id="GC" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
<input type="button" onClick="ingresoneto();" value="Calcule IN" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
Ingreso Neto ($):
<input id="IN" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
Costos Directos ($):
<input type="number" id="CD" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
<input type="button" onClick="margenbruto();" value="Calcule MB" style="background-color: border:1px; text-align: center;">
</p>
<p align="center">
Margen Bruto ($):
<input id="MB" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
Gastos Administrativos ($):
<input type="number" id="GA" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
Gastos de Estructura ($):
<input type="number" id="GE" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
<input type="button" onClick="resultadooperativo();" value="Calcule RO" style="background-color: border:1px; text-align: center;">
</p>
<p align="center">
Resultado Operativo ($):
<input id="RO" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
Amortizaciones indirectas ($):
<input type="number" id="AI" style="background-color: border:1px; text-align: center;"/>
</p>
<p align="center">
<input type="button" onClick="resultadoporproduccion();" value="Calcule RO" style="background-color: border:1px; text-align: center;">
</p>
<p align="center">
Resultado por Producción ($):
<input id="RPP" style="background-color: border:1px; text-align: center;"/>
</p>
</form>
</body>
En este caso B, E, G, H y J deberían funcionar de igual manera. Sé que repitiéndolo funciona. Pero se te ocurre algo mejor y más simple? En función de que como este módulo tengo que hacer tantos otros y ver como lo resuelvo mejor para no enloquecerme repitiéndolo a cada rato.
¡Gracias!