Skip to content

Instantly share code, notes, and snippets.

@tdouce
Created February 25, 2010 16:25
Show Gist options
  • Save tdouce/314687 to your computer and use it in GitHub Desktop.
Save tdouce/314687 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>JavaScript Alert Boxes</title>
<script language="JavaScript">
function rwhcal(area,precip,eff,capt)
{
var total = (area*precip*(eff/100)*(capt/100)*0.623);
var total_rnd = Math.round(total);
alert("You can capture approximately " + total_rnd + " gallons of water off your roof annually!");
}
</script>
</head>
<body>
Enter Area: <input type='text' id='txtArea'/><br/>
Enter Precip: <input type='text' id='txtPrecip'/><br/>
Enter Efficiency: <input type='text' id='txtEff'/><br/>
Enter Percent Capture Area: <input type='text' id='txtCapt'/><br/>
<input type='button' value='Calculate Rainwater Capture Volume' onclick="rwhcal(
parseFloat(document.getElementById('txtArea').value),
parseFloat(document.getElementById('txtPrecip').value),
parseFloat(document.getElementById('txtCapt').value),
parseFloat(document.getElementById('txtEff').value))"/>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment