Wednesday, 7 August 2013

Why am I not getting the right value?

Why am I not getting the right value?

<html>
<head><title>One rep max</title>
<script type="text/javascript">
function calculateOneRepMax(){
var p = document.getElementById("button");
p.onclick = showAlert;
}
function showAlert(){
var weight = document.getElementById("weight").value;
var reps = document.getElementById("reps").value;
var orm = ((weight * reps )/ 30) + weight;
alert(orm);
}
</script>
</head>
<body onload="calculateOneRepMax()">
<form>
Weight: <input type="text" id="weight"/><br>
Reps: <input type="text" id="reps" /><br>
<input id="button" type="button" value="Calculate"
onClick="calculateOneRepMax()" />
</form>
</body>
</html>
I want to create a calculator for one rep max in weightlifting using this
formula. (Weight * Reps)/30 + Weight.
The trouble is that the script is not adding the Weight after (Weight *
Reps)/30. What's wrong here?

No comments:

Post a Comment