Ver Mensaje Individual
  #1 (permalink)  
Antiguo 10/05/2012, 08:59
pinguisport85
 
Fecha de Ingreso: mayo-2011
Mensajes: 101
Antigüedad: 13 años, 9 meses
Puntos: 5
Problema Caluculadora Javascript

Amigos

Ando en busqueda de soluciones, estoy haciendo una calculadora para huella CO2, pero no logro hacerla funcionar, estoy trabajando en HTML + Javscript.
Espero sus ayuda si es posibles.

HTML
Código HTML:
<form action="#" method="get" enctype="application/x-www-form-urlencoded" id="formCalculadora"><div>
<h1>SCOPE1</h1>
<table width="600" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="428" height="25">Consumo de combustible en vehículos</td>
    <td width="172"><input name="COMBUSTIBLE_VH" onkeyup="scope1();" type="text" id="COMBUSTIBLE_VH" value="0" /></td>
  </tr>
  <tr>
    <td height="25">Consumo de combustibles en maquinarias estacionarias productivas</td>
    <td><label>
      <input name="COMBUSTIBLE_MAQ" onkeyup="scope1();" type="text" id="COMBUSTIBLE_MAQ" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25">Consumo combustible en calefactores</td>
    <td><label>
      <input name="COMBUSTIBLE_CALEFA" onkeyup="scope1();" type="text" id="COMBUSTIBLE_CALEFA" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25">Consumo de gases refrigerantes</td>
    <td><label>
      <input name="GASES_REFRI" onkeyup="scope1();" type="text" id="GASES_REFRI" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25"><strong>Huella de carbono Total:</strong></td>
    <td><label>
      <input name="TOTAL_SCOPE1" type="text" id="TOTAL_SCOPE1" value="0" readonly="readonly" />
    </label></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">&nbsp;</td>
  </tr>
  <tr>
    <td height="25"><strong>Huella de carbono:</strong></td>
    <td><label>
      <input name="TOTAL_SCOPE2" type="text" id="TOTAL_SCOPE2" value="0" />
    </label></td>
  </tr>
  </table>
  <input name="SISTEMA_ELEC" onkeyup="scope2" type="text" id="SISTEMA_ELEC" value="0" />
</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="TRANS_MAT_PRIMAS" onkeyup="scope3();" type="text" id="TRANS_MAT_PRIMAS" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25">Transporte de Insumos de producción </td>
    <td><label>
      <input name="TRANS_INS_PRODUC" onkeyup="scope3();" type="text" id="TRANS_INS_PRODUC" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25">Transporte de Insumos de Oficina y aseo </td>
    <td><label>
      <input name="TRANS_INSU_OFI_ASEO" onkeyup="scope3();" type="text" id="TRANS_INSU_PRODUC" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25">Transporte de Residuos </td>
    <td><label>
      <input name="TRANS_RESIDUOS" onkeyup="scope3();" type="text" id="TRANS_RESIDUOS" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25">Transporte de trabajadores</td>
    <td><label>
      <input name="TRANS_TRABAJA" onkeyup="scope3();" type="text" id="TRANS_TRABAJA" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25">Viajes de negocios </td>
    <td><label>
      <input name="VIAJES_NEG" onkeyup="scope3();" type="text" id="VIAJES_NEG" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25">Residuos a reciclaje</td>
    <td><label>
      <input name="RESI_RECI" onkeyup="scope3();" type="text" id="RESI_RECI" value="0" />
    </label></td>
  </tr>
  <tr>
    <td height="25"><strong>Huella de carbono Total:</strong></td>
    <td><label>
      <input name="TOTAL_SCOPE3" type="text" id="TOTAL_SCOPE3" value="0" readonly="readonly" />
    </label></td>
  </tr>
</table></div>
<div>
  <h1>Emite un total de: 
    <label>
    <input name="TOTAL_HUELLA" type="text" id="TOTAL_HUELLA" value="0" />
  </label>
ton CO2-e/año.</h1></div>
</form> 
Java
Código PHP:
/* CALCULAR DATOS */
function scope1()
{
    
kerosene 0.002712802;
    
gasNatural 0.002299518;
    
ConsumoCombustibleVH document.form_calculadora.COMBUSTIBLE_VH.value;
    
ConsumoCombustibleMQ document.form_calculadora.COMBUSTIBLE_MAQ.value;
    
ConsumoCombustibleCalefa document.form_calculadora.COMBUSTIBLE_CALEFA.value;
    
ConsumoGasesRefri document.form_calculadora.GASES_REFRI.value;
    
    
valor = (ConsumoCombustibleVH+ConsumoCombustibleMQ+ConsumoCombustibleCalefa+ConsumoGasesRefri*kerosene*gasNatural)/10000;
    
valor Math.round(valor*1000000)/1000000
    
if(!isNaN(valor) && valor !='infinity')
    {
        
document.form_calculadora.TOTAL_SCOPE1.valuevalor;
    }
    
calcularTotal();    
}
/* CALCULAR DATOS SCOPE2 */
function scope2()
{
    
electricidad 0.333;
    
SistemaElectrico document.form_calculadora.SISTEMA_ELEC.value;
        
        
valor = (SistemaElectrico*electricidad)/1000;
        
valor Math.round(valor*1000000)/1000000;
        if(!
isNaN(valor) && valor != 'Infinity')
        {
            
document.form_calculadora.auto_total.value valor;
        }
    
calcularTotal();
    
}
/* CALCULAR DATOS SCOPE3 */
function calculoTransporte()
{
    
metro 0.0224864515555556;
    
bus 0.0384707650311;
    
TransporteMateriasPrim document.form_calculadora.TRANS_MAT_PRIMAS.value;
    
TransporteInsumosProduc document.form_calculadora.TRANS_INS_PRODUC.value;
    
TransporteInsumosOfi document.form_calculadora.TRANS_INSU_OFI_ASEO.value;
    
TransporteResiduos document.form_calculadora.TRANS_RESIDUOS.value;
    
TransporteTrabaja document.form_calculadora.TRANS_TRABAJA.value;
    
ViajesNegocios document.form_calculadora.VIAJES_NEG.value;
    
ResiduosResiclaje document.form_calculadora.RESI_RECI.value;
    
    
valor = (TransporteMateriasPrim*TransporteInsumosProduc+TransporteInsumosOfi*TransporteResiduos+TransporteTrabaja-ViajesNegocios*ResiduosResiclaje)/1000
    valor 
Math.round(valor*1000000)/1000000;
    if(!
isNaN(valor) && valor != 'Infinity')
    {
        
document.form_calculadora.TOTAL_SCOPE3.value valor;
    }
    
calcularTotal();
}

function 
calcularTotal()
{
    
valorTotalscope1 parseFloat(document.form_calculadora.TOTAL_SCOPE1.value);
    
valorTotalscope2 parseFloat(document.form_calculadora.TOTAL_SCOPE32.value);
    
valorTotalscope3 parseFloat(document.form_calculadora.TOTAL_SCOPE3.value);

    
    
valorCalculoTotal valorTotalscope1 valorTotalscope2 valorTotalscope3;
    
//alert(valorCalculoTotal);
    
valorCalculoTotal Math.round(valorCalculoTotal*1000)/1000;
    if(!
isNaN(valor) && valor != 'Infinity')
    {
        
document.getElementById('valorTotal').innerHTML valorCalculoTotal;
    }
}

function 
verComparacion()
{
    $(
'.ico_ecologico').animate({opacity0},'fast');
    $(
'#formCalculadora').slideUp('normal');
    $(
'#cuadroComparacion').slideDown('slow');
    $(
'#link_compare').slideUp('slow');
    $(
'#link_volver_calculadora').slideDown('slow');
}
function 
ocultarComparacion()
{
    $(
'.ico_ecologico').animate({opacity1},'slow');
    $(
'#formCalculadora').slideDown('normal');
    $(
'#cuadroComparacion').slideUp('fast');
    $(
'#link_compare').slideDown('fast');
    $(
'#link_volver_calculadora').slideUp('fast');