UltraMegaOK1988
07-30-2007, 08:02 AM
I'm trying to create a little calculator for myself that will calculate a baseball team's expected win-loss record.
The formula is (Runs Scored per game + Runs Allowed per game) ^ .287
Since I don't have their runs scored/allowed per game, but I do have their total runs scored/allowed, I'm just going to add those together and divide it by the number of games they've played.
If you don't understand baseball, that probably doesn't make much sense, but I feel I'm pretty close to having this working, and I feel I know where my errors lie, but I'm not sure how to correct them.
Here's what I have:
<html>
<head>
SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function solvepy(form) {
a = parseInt(form.a.value);
b = parseInt(form.b.value);
d = parseInt(form.d.value);
form.c.value = Math.pow(((a+b)/d), .287)
}
// End -->
</script>
</head>
<body>
<a href="http://www.hardballtimes.com/main/statpages/glossary/#pyth" target="newwin">PythagenPat</a><br><br>
(Runs Scored per Game + Runs Allowed per Game) ^ .287<br><br>
In short, (RS/G+RA/G)^.287<br><br>
<form>
<input type=text name=a size=5> - Total Runs Scored<br>
<input type=text name=b size=5> - Total Runs Allowed<br>
<input type=text name=d size=5> - Total Games Played
<br><br>
<input type=button value="Calculate PWL" onClick="solvepy(this.form)">
<br><br>
<input type=text name=c size=5> - PWL
</form>
</body>
</html>
The bolded part is where I think my problems lie.
Thanks for any help that you can provide.
The formula is (Runs Scored per game + Runs Allowed per game) ^ .287
Since I don't have their runs scored/allowed per game, but I do have their total runs scored/allowed, I'm just going to add those together and divide it by the number of games they've played.
If you don't understand baseball, that probably doesn't make much sense, but I feel I'm pretty close to having this working, and I feel I know where my errors lie, but I'm not sure how to correct them.
Here's what I have:
<html>
<head>
SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function solvepy(form) {
a = parseInt(form.a.value);
b = parseInt(form.b.value);
d = parseInt(form.d.value);
form.c.value = Math.pow(((a+b)/d), .287)
}
// End -->
</script>
</head>
<body>
<a href="http://www.hardballtimes.com/main/statpages/glossary/#pyth" target="newwin">PythagenPat</a><br><br>
(Runs Scored per Game + Runs Allowed per Game) ^ .287<br><br>
In short, (RS/G+RA/G)^.287<br><br>
<form>
<input type=text name=a size=5> - Total Runs Scored<br>
<input type=text name=b size=5> - Total Runs Allowed<br>
<input type=text name=d size=5> - Total Games Played
<br><br>
<input type=button value="Calculate PWL" onClick="solvepy(this.form)">
<br><br>
<input type=text name=c size=5> - PWL
</form>
</body>
</html>
The bolded part is where I think my problems lie.
Thanks for any help that you can provide.