1
When trying to perform the click event, returns the following message in the console:
Uncaught Typeerror: Cannot read Property 'value' of null at calculatorWidth (square.js:3) at Htmlinputelement.onclick (index.html:10)
<html>
<head>
<meta charset="utf-8">
<title>Exercicios</title>
<script type="text/javascript" src="quadrado.js"></script>
</head>
<body>
Números <input type="text" name="txtNumeros">
<input type="button" value="Calcular quadrado!" onclick="calcularQuadrado()">
</body>
</html>
Filing cabinet js square.
function calcularQuadrado() {
var numeros = document.getElementById("txtNumeros").value;
numeros = numeros.split("-");
for (i=0; i=numeros.length; i++){
quadrado = parseInt(numeros[i])*parseInt(numeros[i]);
document.write("O quadrado de "+numeros[i]+ " é "+quadrado+"<br>");
}
}
Precise, fast and functional! Thank you truly!
– Gabriel Melo