I did check for any missing curly brace or semi-colon etc.
If someone could please check the code and tell me what am I missing here.
Thanks
<html>
<head>
<title>MATH USING Javascript</title>
<script type="text/javascript" src="mathCalc.js"></script>
</head>
<body>
<h1>MATH USING Javascript</h1>
<p>How to calculate the circumference of a given radius?</p>
<p>Please enter radius:<input type="text" id="enterRadius"></p>
<p><input type="button" value="calculate" id="calcRadius"></p>
<p><id="message"></p>
</body>
</html>
// now the js file
function init()
{
var myButton = document.getElementById("calcRadius");
myButton.onclick = calcAnswer;
}
onload = init;
function calcAnswer()
{
var rad = document.getElementById("enterRadius");
var myrad = parseInt(rad.value);
var myMessage = document.getElementById("message");
if(isNan(myrad))
{
alert("Please enter a number!");
}
else
{
var calcradius = 2 * (Math.PI * myrad);
var myMessage = document.getElementById("message");
myMessage.innerHTML = calcradius;
}
}

New Topic/Question
Reply



MultiQuote





|