Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <script type="text/javascript">
- <!-- Original: James P. Dildine (jpd@wlsmail.com) -->
- <!-- Web Site: http://www.mste.uiuc.edu/dildine -->
- function windChill(form) {
- //error checking
- if (isNaN(form.wind.value) || isNaN(form.temp.value)) {
- if (isNaN(form.wind.value) && isNaN(form.temp.value)) {
- alert("The value you wrote in both text boxes are not valid numbers.");
- form.wind.value = "";
- form.temp.value = "";
- form.wind.focus();
- } else {
- if (isNaN(form.wind.value)) {
- alert("The value you wrote in the wind speed text box is not a valid number.");
- form.wind.value = "";
- form.wind.focus();
- } else {
- alert("The value you wrote in the air temperature text box is not a valid number.");
- form.temp.value = "";
- form.temp.focus();
- }
- }
- form.windchill.value = "";
- return false;
- }
- //calculate wind chill
- var wind = eval(form.wind.value);
- var temp = eval(form.temp.value);
- var chill = (0.0817*(3.71*(Math.pow(wind, 0.5))+5.81-0.25*wind)*(temp-91.4)+91.4);
- form.windchill.value = chill;
- return false;
- }
- </script>
- </head>
- <body>
- <form name="windform">
- <div style="padding-left: 50%; margin-left: -130px;">
- <div style="float: left; margin-right: 10px; width: 130px;">
- <p style="margin: 15px 0;"> Wind Speed (MPH)</p>
- <p style="margin: 15px 0;">Air Temperature (ºF)</p>
- </div>
- <div style="float: left; width: 130px;">
- <input type="text" id="wind" name="wind" style="display: block; margin: 15px 0;">
- <input type="text" id="temp" name="temp" style="display: block; margin: 15px 0;">
- </div>
- </div>
- <div style="clear: both; text-align: center;">
- <input type="submit" value="Calculate Wind Chill" onclick="return windChill(this.form)">
- <br>
- <input name="windchill" type="text" style="margin-top: 15px;"> ºF
- </div>
- </form>
- </body>
- </html>
Add Comment
Please, Sign In to add comment