Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head lang="pl">
- <meta charset="UTF-8">
- </head>
- <body>
- Podaj boki prostopadłościanu:
- <form>
- Bok a: <input type="text" id="a" name="a"/>
- Bok b: <input type="text" id="b" name="b"/>
- Bok h: <input type="text" id="h" name="h"/>
- <br/><input type="button" id="button" value="Wyślij"></input>
- </form>
- <div id="output"></div>
- <script>
- function obliczenia(){
- var a=document.getElementById('a');
- var b=document.getElementById('b');
- var h=document.getElementById('h');
- var wynik;
- if(a.value.length==0)
- {
- output.innerHTML=("Pole z wartością A nie może być puste");
- }
- else if (b.value.length==0)
- {
- output.innerHTML=("Pole z wartością B nie może być puste");
- }
- else if (h.value.length==0)
- {
- output.innerHTML=("Pole z wartością H nie może być puste");
- }
- else if(isNaN(a.value) || isNaN(b.value) || isNaN(h.value))
- {
- output.innerHTML=("Pola muszą zawierać liczby!");
- }
- else if(0>a.value || 0>b.value || 0>h.value)
- {
- output.innerHTML=("Wartości muszą być większe od 0!")
- }
- else
- {
- wynik=Math.sqrt(a.value*a.value+b.value*b.value+h.value*h.value);
- output.innerHTML=("Przekątna prostopadłościanu wynosi: "+wynik);
- }
- }
- button.onclick=function(){
- obliczenia();
- return false;
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement