Jump to content

IMC en javascript


Recommended Posts

alguien que me diga este codigo xfa...

 

gracias (Y)

 

esto no es pedido de scripts. lee bien de que trata cada rincon antes de postiar, pide que lo cambien de lugar

de todos modos te dejo una manera que en que podrias obtener el IMC por javascript

 

<html>

<head>

<title>Cacluladora de IMC</title>

 

<script LANGUAGE="JavaScript">

function checkIt(evt) {

evt = (evt) ? evt : window.event

var charCode = (evt.which) ? evt.which : evt.keyCode

if (charCode > 31 && (charCode < 48 || charCode > 57)) {

status = "This field accepts numbers only."

return false

}

status = ""

return true

}

 

function calc()

{

var masa1 = document.getElementById('masa').value;

var altura1 = document.getElementById('high').value;

masa = parseFloat(masa1);

altura = parseFloat(altura1)/100;

if(altura == 0)

{

document.getElementById('imc').value='N/A';

}

else

{

imc = masa/(altura*altura);

document.getElementById('imc').value=imc;

}

}

</SCRIPT>

 

 

</head>

<body>

 

 

<table>

<tr>

<td>Masa en kilos:</td>

<td><input type="text" id="masa" size="3" maxlength="3" onkeypress="return checkIt(event); calc();" /></td>

</tr>

<tr>

<td>Estatura en centimetros:</td>

<td><input type="text" id="high" size="3" maxlength="3" onkeypress="return checkIt(event); calc();" /></td>

</tr>

<tr>

<td>IMC</td>

<td><input type="text" id="imc" disabled="true" size="3" /></td>

</tr>

<tr>

<td colspan="2"><input type="button" onclick="calc();" value="Calcular"/></td>

</tr>

</table>

 

</body>

</html>

Edited by alvaroxz
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...