Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <html lang="pl">
  4. <head>
  5. <meta charset="utf-8">
  6. <title> JavaScript: tworzenie i odwoływaie się do obiektów. </title>
  7.  
  8.  
  9. </head>
  10. <body>
  11. Podaj dane Matki: <br>
  12. Imie <input id="imie1" type="text"><br>
  13. Nazwisko: <input id="nazwisko1" type="text"><br>
  14. Wiek: <input id="wiek1" type="text"><br><br>
  15. Podaj dane Ojca: <br><br>
  16. Imie: <input id="imie2" type="text"><br>
  17. Nazwisko: <input id="nazwisko2" type="text"><br>
  18. Wiek: <input id="wiek2" type="text"><br>
  19. <button type = "button" onclick="Push()"> Wpisz</button>
  20.  
  21. <p id = "paragraf1"></p>
  22. <p id = "paragraf2"></p>
  23.  
  24. <script>
  25.  
  26. function Push(){
  27.  
  28. var P1 = {
  29.  
  30. Imie: document.getElementById("imie1").value,
  31. Nazwisko: document.getElementById("nazwisko1").value,
  32. Wiek: Number(document.getElementById("wiek1").value),
  33. daneWyjcie: function(){
  34.  
  35. return "Imie matki: " + this.Imie + "</br>" + "Nazwisko matki:" + this.Nazwisko + "</br>" + "Wiek: " + this.Wiek;
  36.  
  37.  
  38. }
  39. };
  40.  
  41.  
  42.  
  43. document.getElementById("paragraf1").innerHTML = P1.daneWyjcie();
  44. var P2 = {
  45.  
  46. Imie1: document.getElementById("imie2").value,
  47. Nazwisko1: document.getElementById("nazwisko2").value,
  48. Wiek1: Number(document.getElementById("wiek2").value),
  49. daneWyjcie1: function(){
  50.  
  51. return "Imie ojca: " + this.Imie1 + "</br>" + "Nazwisko ojca: " + this.Nazwisko1 + "</br>" + "Wiek: " + this.Wiek1;
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58. };
  59. document.getElementById("paragraf2").innerHTML = P2.daneWyjcie1();
  60.  
  61.  
  62.  
  63. }
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. </script>
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. </body>
  82. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement