Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE HTML>
- <html lang="pl">
- <head>
- <meta charset="utf-8">
- <title>Stacja Meteo</title>
- </head>
- <body>
- <div id="form1">
- <h2>Zamiana jednostek temperatury w <sup>o</sup>C<br></h2>
- <form name="form1">
- <label for="liczba">
- <input type="text" id="liczba"/><br>
- <br> </label>
- Zamień na <br>
- <input type="button"
- onclick="kelwiny();" value="Kelwiny"/>
- <input type="button"
- onclick="far();"
- value="Farenheit"/>
- </form>
- <div id="wynik">TU WYNIK</div><br/>
- <script type="text/javascript">
- function kelwiny()
- {
- var x = document.getElementById("liczba").value;
- if(x=='' || isNaN(x))
- {
- alert("Należy wpisać wartość liczbową");
- }
- else
- {
- x=parseFloat(x);
- var wynik=x+273.15;
- document.getElementById("wynik").innerHTML = wynik+"K";
- }
- }
- function farenheity()
- {
- var x = document.getElementById("liczba").value;
- if(x=="" || isNaN(x))
- {
- alert("Należy wpisać wartość liczbową");
- }
- else
- {
- x=parseFloat(x);
- var wynik=1.8*x+32;
- document.getElementById("wynik").innerHTML = wynik+"F";
- }
- }
- </script>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement