Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>WCF</title>
- <script type="text/javascript">
- function computeWCF(temp, ws){
- if(temp > 50){
- //display an error message
- document.getElementById('errorH3').innerHTML = 'Error-- '
- return NaN
- }
- else{
- if (ws <= 3) {
- return temp
- }
- else {
- return (35.74 + 0.6215 * temp + (0.4275 * temp - 35.75) * Math.pow(ws, 0.16))
- }
- }
- </script>
- </head>
- <body>
- <form>
- <p/>Wind Speed:
- <input type='text' id='ws' value =""/>
- <p/>Temperature:
- <input type='text' id='temp'/>
- <p/>
- <input type='button' value='computeWCF'
- onclick= "var ws = parseFloat(document.getElementById('ws').value);
- var temp = parseFloat(document.getElementById('temp').value);
- document.getElementById('wcf').value = computeWCF(temp, ws);"/>
- <hr/>
- <p> The Wind Chill Factor is: <input type="text" id="wcf" size="4" value="" />
- </p>
- </form>
- <h3> id='errorH3'> </h3>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement