Amigos
Sorry que sea majadero , pero estoy buelto loco con esto, estoy haciendo un calculadora para medir el HUella CO2, lo trabaje en HTML y Java y no realiza los calculos, me puedes ayudar ?
HTML
Código HTML:
<body>
<form action="#" enctype="application/x-www-form-urlencoded" id="formCalculadora"><div>
<h1>SCOPE1</h1>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="329" height="25">Consumo de combustible en vehículos</td>
<td width="150"><input name="combustuble_vh" type="text" id="combustuble_vh" value="0" onkeyup=scope1 /></td>
<td width="121"> </td>
</tr>
<tr>
<td height="25">Consumo de combustibles en maquinarias estacionarias productivas</td>
<td><label>
<input name="combustible_maq" type="text" id="combustible_maq" value="0" onkeyup=scope1 />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25">Consumo combustible en calefactores</td>
<td><label>
<input name="combustible_calefac" type="text" id="combustible_calefac" value="0" onkeyup=scope1 />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25">Consumo de gases refrigerantes</td>
<td><label>
<input name="gases_refri" type="text" id="gases_refri" value="0" onkeyup=scope1 />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>Huella de carbono Total:</strong></td>
<td><label>
<input name="totalscope1" type="text" id="totalscope1" value="0" readonly="readonly" />
</label></td>
<td> </td>
</tr>
</table>
</div>
<div>
<h1>SCOPE2</h1>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="427" height="25">Electricidad de sistema eléctrico</td>
<td width="173"><input name="sistema_electric" type="text" id="sistema_electric" value="0" /></td>
<td width="173"> </td>
</tr>
<tr>
<td height="25"><strong>Huella de carbono:</strong></td>
<td><label>
<input name="totalscope2" type="text" id="totalscope2" value="0" />
</label></td>
<td> </td>
</tr>
</table>
</div>
<div>
<h1>SCOPE3</h1>
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="427" height="25">Transporte de Materias Primas </td>
<td width="173"><label>
<input name="transMaterPrimas" type="text" id="transMaterPrimas" value="0" />
</label></td>
<td width="173"> </td>
</tr>
<tr>
<td height="25">Transporte de Insumos de producción </td>
<td><label>
<input name="transInsumosProduc" onkeyup="scope3();" type="text" id="transInsumosProduc" value="0" />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25">Transporte de Insumos de Oficina y aseo </td>
<td><label>
<input name="transInsuOfiAseo" type="text" id="transInsuOfiAseo" value="0" />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25">Transporte de Residuos </td>
<td><label>
<input name="transResiduos" type="text" id="transResiduos" value="0" />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25">Transporte de trabajadores</td>
<td><label>
<input name="transTrabajadores" type="text" id="transTrabajadores" value="0" />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25">Viajes de negocios </td>
<td><label>
<input name="viajesNegocios" type="text" id="viajesNegocios" value="0" />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25">Residuos a reciclaje</td>
<td><label>
<input name="residuosReciclaje" type="text" id="residuosReciclaje" value="0" />
</label></td>
<td> </td>
</tr>
<tr>
<td height="25"><strong>Huella de carbono Total:</strong></td>
<td><label>
<input name="totalscope3" type="text" id="totalscope3" value="0" readonly="readonly" />
</label></td>
<td> </td>
</tr>
</table>
</div>
<div>
<input name="calcular" type="button" value="Calcular" />
</div>
<div>
<h1>Emite un total de:
<label>
<input name="totalHuellas" type="text" id="totalHuellas" value="0" />
</label>
ton CO2-e/año.</h1></div>
</form>
</body>
JAVA
Código PHP:
// JavaScript Document
/* CALCULAR DATOS */
function scope1()
{
ConsumoCombustibleVH = document.form_calculadora.combustuble_vh.value;
ConsumoCombustibleMQ = document.form_calculadora.combustible_maq.value;
ConsumoCombustibleCalefa = document.form_calculadora.combustible_calefac.value;
ConsumoGasesRefri = document.form_calculadora.gases_refri.value;
valor = (((ConsumoCombustibleVH*500)+(ConsumoCombustibleMQ*500)+(ConsumoCombustibleCalefa*500)+(ConsumoGasesRefri*500)+400)*500)/2;
valor = Math.round(valor*1000000)/1000000
if(!isNaN(valor) && valor !='infinity')
{
document.form_calculadora.totalscope1.value= valor;
}
calcularTotal();
}
/* CALCULAR DATOS SCOPE2 */
function scope2()
{
SistemaElectrico = document.form_calculadora.sistema_electric.value;
valor = ((SistemaElectrico*500)+500)/2;
valor = Math.round(valor*1000000)/1000000;
if(!isNaN(valor) && valor != 'Infinity')
{
document.form_calculadora.totalscope2.value = valor;
}
calcularTotal();
}
/* CALCULAR DATOS SCOPE3 */
function scope3()
{
TransporteMateriasPrim = document.form_calculadora.transMaterPrimas.value;
TransporteInsumosProduc = document.form_calculadora.transInsumosProduc.value;
TransporteInsumosOfi = document.form_calculadora.transInsuOfiAseo.value;
TransporteResiduos = document.form_calculadora.transResiduos.value;
TransporteTrabaja = document.form_calculadora.transTrabajadores.value;
ViajesNegocios = document.form_calculadora.viajesNegocios.value;
ResiduosResiclaje = document.residuosReciclaje.value;
valor = ((TransporteMateriasPrim*500)+(TransporteInsumosProduc*500)+(TransporteInsumosOfi*500)+(TransporteResiduos*500)+(TransporteTrabaja*500)+(ViajesNegocios*500)+(ResiduosResiclaje*500)+700)/2;
valor = Math.round(valor*1000000)/1000000;
if(!isNaN(valor) && valor != 'Infinity')
{
document.form_calculadora.totalscope3.value = valor;
}
calcularTotal();
}
function calcularTotal()
{
valorTotalscope1 = parseFloat(document.form_calculadora.totalscope1.value);
valorTotalscope2 = parseFloat(document.form_calculadora.totalscope2.value);
valorTotalscope3 = parseFloat(document.form_calculadora.totalscope3.value);
valorCalculoTotal = valorTotalscope1 + valorTotalscope2 + valorTotalscope3;
//alert(valorCalculoTotal);
valorCalculoTotal = Math.round(valorCalculoTotal*1000)/1000;
if(!isNaN(valor) && valor != 'Infinity')
{
document.getElementById('valorTotal').innerHTML = valorCalculoTotal;
}
}