You should show to us the code to which you're stumped at. Anyway, I'm bored:
HTML Code:
<script type="text/javascript">
function calcHeartRate()
{
var max=0,min=0,result=0,sub=220, // Initialize some variables
age=document.getElementById('age'), // Textbox that accepts the age
show=document.getElementById('result'); // Textbox to show the result
age=Number(age.value);
if(isNaN(age)) alert('Please provide a number.'); // If not a number
else
{
max=(sub-age)*(0.85); // Get the max heart beat
min=(sub-age)*(0.5); // Get the min heart beat
max=(Math.floor(max)); // Round downwards to the nearest integer
min=(Math.floor(min)); // Round downwards to the nearest integer
show.value=min+' to '+max+' beats per minute';
}
}
</script>
<label for="age">Age: </label><input type="text" id="age">
<input type="button" value="Calculate Heart Beat" onclick="calcHeartRate()">
<input type="text" id="result" readonly="readonly" style="width:200px;">
Bookmarks