Created
February 17, 2010 16:27
-
-
Save tdouce/306773 to your computer and use it in GitHub Desktop.
Revisions
-
tdouce revised this gist
Feb 17, 2010 . 1 changed file with 65 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,23 +4,79 @@ <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <script type='text/javascript'> function formValidator(){ // Make quick references to our fields var roof = document.getElementById('txtRoof'); var precip = document.getElementById('txtPrecip'); var eff = document.getElementById('txtEff'); var capt_area = document.getElementById('txtArea'); // Check each input in the order that it appears in the form! if(isNumeric(roof, "Please enter a value for the roof area.")){ if(isNumeric(precip, "Please enter a precipitation value.")){ if(isNumeric(eff, "Please enter an efficiency value.")){ if(isNumeric(capt_area, "Please enter a capture area value.")){ return true; } } } } return false; } function notEmpty(elem, helperMsg){ if(elem.value.length == 0){ alert(helperMsg); elem.focus(); // set the focus to this input return false; } return true; } function isNumeric(elem, helperMsg){ var numericExpression = /^[0-9]+$/; if(elem.value.match(numericExpression)){ return true; }else{ alert(helperMsg); elem.focus(); return false; } } function calculate() { var roof = document.roof.txtRoof.value; var precip = document.precip.txtPrecip.value; var eff = document.eff.txtEff.value; var eff_percent = (eff/100); var conv_factr = 0.623; var capt_area = document.area.txtArea.value; 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.write("Approximately " + total_rnd + " gallons can be collected off your roof annualy."); } </script> <body> <form onsubmit='return formValidator()' > 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 <br/>to caputure rain (%)<input type='text' id='txtEff' /><br /> The amount of roof area from which <br/> you are going to caputure rain (%) <input type='text' id='txtArea' /><br /> <input type='submit' value='Check Form' onclick='calculate()'/> </form> </body> </html> -
tdouce created this gist
Feb 17, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ <!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"> <head> <script type="text/javascript"> </script> </head> <body> Text Area 1: <input type=text id="txtRoof"><br/> Text Area 2: <input type='text' id='txtPrecip'/><br/> <input type=button value="Calculate" onclick="doNumberTest()"><br/> Answer: <input type=text id="txtResult" size=10><br/> </body> </html>