Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <html lang="pl">
- <head>
- <meta charset="utf-8">
- <title> JavaScript: tworzenie i odwoływaie się do obiektów. </title>
- </head>
- <body>
- Podaj dane Matki: <br>
- Imie <input id="imie1" type="text"><br>
- Nazwisko: <input id="nazwisko1" type="text"><br>
- Wiek: <input id="wiek1" type="text"><br><br>
- Podaj dane Ojca: <br><br>
- Imie: <input id="imie2" type="text"><br>
- Nazwisko: <input id="nazwisko2" type="text"><br>
- Wiek: <input id="wiek2" type="text"><br>
- <button type = "button" onclick="Push()"> Wpisz</button>
- <p id = "paragraf1"></p>
- <p id = "paragraf2"></p>
- <script>
- function Push(){
- var P1 = {
- Imie: document.getElementById("imie1").value,
- Nazwisko: document.getElementById("nazwisko1").value,
- Wiek: Number(document.getElementById("wiek1").value),
- daneWyjcie: function(){
- return "Imie matki: " + this.Imie + "</br>" + "Nazwisko matki:" + this.Nazwisko + "</br>" + "Wiek: " + this.Wiek;
- }
- };
- document.getElementById("paragraf1").innerHTML = P1.daneWyjcie();
- var P2 = {
- Imie1: document.getElementById("imie2").value,
- Nazwisko1: document.getElementById("nazwisko2").value,
- Wiek1: Number(document.getElementById("wiek2").value),
- daneWyjcie1: function(){
- return "Imie ojca: " + this.Imie1 + "</br>" + "Nazwisko ojca: " + this.Nazwisko1 + "</br>" + "Wiek: " + this.Wiek1;
- }
- };
- document.getElementById("paragraf2").innerHTML = P2.daneWyjcie1();
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement