Skip to content

Instantly share code, notes, and snippets.

@tdouce
Created February 26, 2010 19:08
Show Gist options
  • Save tdouce/316037 to your computer and use it in GitHub Desktop.
Save tdouce/316037 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>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type='text/javascript'>
function calculate()
{
var roof = parseFloat(document.getElementById('txtRoof').value);
var precip = parseFloat(document.getElementById('txtPrecip').value);
var eff = parseFloat(document.getElementById('txtEff').value);
var eff_percent = (eff/100);
var conv_factr = 0.623;
var capt_area = parseFloat(document.getElementById('txtArea').value);
var capt_area_percent = (capt_area/100);
var capt_area_percent = (capt_area/100);
var total = (roof * precip * conv_factr * capt_area_percent * eff_percent);
var total_rnd = Math.round(total);
document.getElementById('output').value=("Approximately " + total_rnd + " gallons can be collected off your roof annualy.");
}
</script>
<body>
<form name='formOne'>
Collection Footprint Area (square feet) <input type='text' id='txtRoof'/><br />
Annual precipitation in your area (inches) <input type='text' id='txtPrecip'/><br />
Efficiency with which you are going to caputure rain (%)<input type='text' id='txtEff' value='80' onFocus="if(this.value == '80') {this.value = '';}" onBlur="if (this.value == '') {this.value = '80';}" /><br />
The amount of roof area from which you are going to caputure rain (%) <input type='text' id='txtArea'/><br />
Result: <textarea id='output' cols='40' rows='2'/></textarea>
<br/><input type='submit' value='Calculate' onClick='calculate()'/><br/>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment