My html code is as follows:
<!DOCTYPE html PUBLIC "-//WC3//DTD XHTML 1.0 Stric//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JavaScript Aula 07</title>
<script type="text/javascript" src="js/aula07.js"></script>
<style type="text/css">
img, table { width:165px; }
fieldset { width:140px; }
label { display:block; float:left;}
label, input {width:68px; margin:3px 0; }
th, td {border:1px solid #ccc; font-size:0.8em;}
</style>
</head>
<body>
<img src="img/imc.png" alt="imc"/>
<form id="formulario">
<fieldset>
<legend>Cálculo do IMC</legend>
<label for="kilos">Quilos:</label>
<input type="text" name="quilos"/>
<label for="metros">Metros:</label>
<input type="text" name="metros"/>
<label for="centimetros">Cm:</label>
<input type="text" name="centimetros"/>
<label for="imc">IMC:</label>
<input type="text" name="imc" disabled="disabled"/>
<a href="#" onclick="calcularIMC()">Calcular</a>
</fieldset>
</form>
</body>
</html>
And the JavaScript is:
calcularIMC = function (){
var formulario = document.getElementById("formulario");
var kilos = +formulario.kilos.value;
var metros = +formulario.metros.value;
var centimetros = +formulario.centimetros.value;
var altura = (metros*100 + centimetros)/100;
var imc = kilos / (altura * altura);
formulario.imc.value = imc.toFixed(2);
}
When using Notepad ++, the HTML page does not seem to be "calling" JavaScript, so no results appear in the IMC field. Thanks to anyone who can help.