Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>Javascript: Tworzenie i odwoływanie się do obiektów.</title>
  6. </head>
  7. <body>
  8. Imię Ojca <input id="imie ojca">
  9. Nazwisko Ojca <input id="nazwisko ojca">
  10. Wiek Ojca <input id="wiek ojca"><br>
  11. Imię Matki <input id="imie matki">
  12. Nazwisko Matki <input id="nazwisko matki">
  13. Wiek Matki <input id="wiek matki"><br>
  14. <button onclick = "ok()">Zapisz</button>
  15. <p id="paragraf1"></p>
  16. <p id="paragraf2"></p>
  17.  
  18. <script>
  19. function dane(im, nazw, w){
  20. this.imie=im;
  21. this.nazwisko=nazw;
  22. this.wiek=w;
  23. this.daneWyjscie = function (){
  24. return this.imie+ " "+this.nazwisko+", wiek: " + this.wiek;
  25.  
  26. }
  27. }
  28.  
  29. function ok(){
  30. var O1 = new dane(document.getElementById("imie ojca").value, document.getElementById("nazwisko ojca").value, document.getElementById("wiek ojca").value);
  31. document.getElementById("paragraf1").innerHTML=O1.daneWyjscie();
  32.  
  33. var O2 = new dane(document.getElementById("imie matki").value, document.getElementById("nazwisko matki").value, document.getElementById("wiek matki").value);
  34. document.getElementById("paragraf2").innerHTML=O2.daneWyjscie();
  35. }
  36. </script>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement