WK_of_Angmar

Yahoo! Answers - jumpingrightin's Question

Jul 30th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 1.79 KB | None | 0 0
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. <!-- Original:  James P. Dildine (jpd@wlsmail.com) -->
  5. <!-- Web Site:  http://www.mste.uiuc.edu/dildine -->
  6.  
  7.  
  8. function windChill(form) {
  9. //error checking
  10. if (isNaN(form.wind.value) || isNaN(form.temp.value)) {
  11.     if (isNaN(form.wind.value) && isNaN(form.temp.value)) {
  12.         alert("The value you wrote in both text boxes are not valid numbers.");
  13.         form.wind.value = "";
  14.         form.temp.value = "";
  15.         form.wind.focus();
  16.     } else {
  17.         if (isNaN(form.wind.value)) {
  18.             alert("The value you wrote in the wind speed text box is not a valid number.");
  19.             form.wind.value = "";
  20.             form.wind.focus();
  21.         } else {
  22.             alert("The value you wrote in the air temperature text box is not a valid number.");
  23.             form.temp.value = "";
  24.             form.temp.focus();
  25.         }
  26.     }
  27.     form.windchill.value = "";
  28.     return false;
  29. }
  30. //calculate wind chill
  31. var wind = eval(form.wind.value);
  32. var temp = eval(form.temp.value);
  33. var chill = (0.0817*(3.71*(Math.pow(wind, 0.5))+5.81-0.25*wind)*(temp-91.4)+91.4);
  34. form.windchill.value = chill;
  35. return false;
  36. }
  37. </script>
  38. </head>
  39. <body>
  40. <form name="windform">
  41.  
  42. <div style="padding-left: 50%; margin-left: -130px;">
  43. <div style="float: left; margin-right: 10px; width: 130px;">
  44. <p style="margin: 15px 0;"> Wind Speed (MPH)</p>
  45. <p style="margin: 15px 0;">Air Temperature (ºF)</p>
  46. </div>
  47.  
  48. <div style="float: left; width: 130px;">
  49. <input type="text" id="wind" name="wind" style="display: block; margin: 15px 0;">
  50. <input type="text" id="temp" name="temp" style="display: block; margin: 15px 0;">
  51. </div>
  52. </div>
  53.  
  54. <div style="clear: both; text-align: center;">
  55. <input type="submit" value="Calculate Wind Chill" onclick="return windChill(this.form)">
  56. <br>
  57. <input name="windchill" type="text" style="margin-top: 15px;"> ºF
  58. </div>
  59. </form>
  60. </body>
  61. </html>
Add Comment
Please, Sign In to add comment