Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. <!-- Harjoitus 1
  2. Harjoituksen tarkoituksena on laskea yhteen kaksi käyttäjän antamaa
  3. lukua ja tulostaa lopputulos tietoja käsittelevälle sivulle.
  4.  
  5. Tiedot lähettävä sivu
  6. Tee sivu lomake_harj1.htm, jonka lomakkeella on kaksi tekstikenttää
  7. yhteenlaskettavia tietoja varten sekä painike tietojen
  8. lähettämiseen. -->
  9. <html>
  10. <head>
  11. <title> Lomakeharjoitus 1, lähettävä sivu</title>
  12. </head>
  13.  
  14. <script language="JavaScript">
  15. // Asettaa kohdistimen ensimmäiseen kenttään
  16. function AsetaKohdistin()
  17. {
  18. document.lomake_harj1.luku1.focus();
  19. document.lomake_harj1.luku2.focus();
  20. }
  21.  
  22. function TarkistaTiedot(Lomake)
  23. {
  24.  
  25. if (Lomake.luku1.value.length == 0)
  26. {
  27. alert("luku1 pitää antaa!");
  28. Lomake.luku1.focus();
  29. return false;
  30. }
  31.  
  32. if (Lomake.luku2.value.length == 0)
  33. {
  34. alert("Luku2 pitää antaa!");
  35. Lomake.luku2.focus();
  36. return false;
  37. }
  38.  
  39.  
  40.  
  41.  
  42. // Kaikki muodollisesti OK, lähetetään lomaketiedot palvelimelle
  43. Lomake.submit();
  44. }
  45. </script>
  46.  
  47. <body onLoad="AsetaKohdistin();">
  48. <h1>Lomakeharjoitus 1, lähettävä sivu</h1><br/>
  49. <p>Kahden luvun yhteenlasku.</p>
  50.  
  51. <form action="tunnilla.lomake_harj1.php" method="post" name="Lomake_harj1.html">
  52. Luku1: <input type="text" name="luku1" /><br/>
  53. Luku2: <input type="text" name="luku2" /><br/>
  54. <input type="button" value="Laske" onClick="TarkistaTiedot(this.form)" />
  55. <input type="reset" value="Tyhjennä" />
  56. </form>
  57. </body>
  58. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement