Ver Mensaje Individual
  #6 (permalink)  
Antiguo 21/11/2007, 11:10
Avatar de rol2007
rol2007
 
Fecha de Ingreso: mayo-2007
Ubicación: Santiasco CHILE
Mensajes: 300
Antigüedad: 17 años
Puntos: 4
Re: Calculos en javascript

Código HTML:
<html>
<body>
<script>
function multiplicar(){
m1 = document.getElementById("superficie").value;
tot= (m1+2)*85;
 
 if (document.Myform.factor1.checked){
 m2 = document.getElementById("factor1").value;
 tot=tot*m2
 }
 if (document.Myform.factor2.checked){
  m2 = document.getElementById("factor2").value;
 tot=tot*m2
}
 if (document.Myform.factor3.checked){
  m2 = document.getElementById("factor3").value;
 tot=tot*m2}
 if (document.Myform.factor4.checked){
  m2 = document.getElementById("factor4").value;
 tot=tot*m2}
 if (document.Myform.factor5.checked){
 m2 = document.getElementById("factor5").value;
 tot=tot*m2
}

 document.getElementById("resultado").value = tot;
 }
</script>
<form   method="post" name="Myform" id="multiplicar" onsubmit="multiplicar();">
                                        <table width="99%" border="0" cellspacing="0" cellpadding="3">
                                          <tr>
                                            <td width="11%" align="left">&nbsp;</td>
                                            <td width="35%" align="left">Factor geogr&aacute;fico:</td>
                                            <td colspan="2" align="left" valign="middle" class="texto"><table width="81%" border="0" cellspacing="3" cellpadding="0">
                                                <tr>
                                                  <td><input name="factor1" type="radio" value="1" id="factor1">
                                                    1</td>
                                                  <td><input name="factor2" type="radio" value="2" id="factor2">
                                                    2</td>
                                                  <td><input name="factor3" type="radio" value="3" id="factor3">
                                                    3</td>
                                                  <td><input name="factor4" type="radio" value="4" id="factor4">
                                                    4</td>
                                                  <td><input name="factor5" type="radio" value="5" id="factor5">
                                                    5</td>
                                                </tr>
                                            </table></td>
                                          </tr>
                                          <tr>
                                            <td align="left">&nbsp;</td>
                                            <td align="left">Superficie de la estancia: </td>
                                            <td width="39%" align="left"><input name="superficie" type="text" class="texto" id="superficie" >
                                              m2</td>
                                            <td width="15%" colspan="-3" rowspan="2" align="left">&nbsp;</td>
                                          </tr>
                                          <tr>
                                            <td align="left">&nbsp;</td>
                                            <td align="left">Tipo de estancia: </td>
                                            <td align="left"><table width="60%" border="0" cellspacing="3" cellpadding="0">
                                                <tr>
                                                  <td width="30%"><input name="estancia" type="radio" value="salon"></td>
                                                  <td width="70%">Sal&oacute;n</td>
                                                </tr>
                                                <tr>
                                                  <td><input name="estancia" type="radio" value="dormitorio"></td>
                                                  <td>Dormitorio</td>
                                                </tr>
                                                <tr>
                                                  <td><input name="estancia" type="radio" value="cocina"></td>
                                                  <td>Cocina</td>
                                                </tr>
                                                <tr>
                                                  <td><input name="estancia" type="radio" value="ba&ntilde;o"></td>
                                                  <td>Ba&ntilde;o</td>
                                                </tr>
                                                <tr>
                                                  <td><input name="estancia" type="radio" value="pasillo"></td>
                                                  <td>Pasillo</td>
                                                </tr>
                                            </table></td>
                                          </tr>
                                          <tr>
                                            <td align="left">&nbsp;</td>
                                            <td align="left">&nbsp;</td>
                                            <td align="left">&nbsp;</td>
                                            <td colspan="-3" align="left">&nbsp;</td>
                                          </tr>
                                          <tr>
                                            <td align="left">&nbsp;</td>
                                            <td align="left">&nbsp;</td>
                                            <td align="left"><input name="resultado" type="text" id="resultado"></td>
                                            <td colspan="-3" align="left"><input type="button" name="Submit" value="Calcular" onclick="multiplicar();" ></td>
                                          </tr>
                                        </table> 
no es la mas apropiada.......pero ahi te hize una muestra, trata de ver otras opciones esta la hize muy apurado.....toy en el trabajo
__________________
Saludos
desde Chile