Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8"/>
- <title>Dworzak to pies</title>
- </head>
- <body>
- Rasa: <div id="name">...</div>
- <br>
- Kolor:
- <div id="color">...</div>
- <br>
- Wiek:
- <div id="age">...</div>
- <br>
- <input type="button" value="Labrador" onclick="createDog(1)"/>
- <input type="button" value="Pudel" onclick="createDog(2)"/>
- <input type="button" value="Buldog" onclick="createDog(3)"/>
- <input type="button" value="Owczarek" onclick="createDog(4)"/>
- <input type="button" value="Beagle" onclick="createDog(5)"/>
- <script>
- function Dog(name, color, age) {
- this.name = name;
- this.color = color;
- this.age = age;
- this.initialize = function() {
- document.getElementById("name").innerHTML = this.name;
- document.getElementById("color").innerHTML = this.color;
- document.getElementById("age").innerHTML = this.age;
- }
- }
- function createDog(x) {
- if (x == 1) {
- const dog = new Dog("Labrador", "Biały", "12 lat");
- dog.initialize();
- }
- if (x == 2) {
- const dog = new Dog("Pudel", "Brązowy", "4 lata");
- dog.initialize();
- }
- if (x == 3) {
- const dog = new Dog("Buldog", "Czarny", "8 lat");
- dog.initialize();
- }
- if (x == 4) {
- const dog = new Dog("Owczarek", "Biało-brązowy", "5 lat");
- dog.initialize();
- }
- if (x == 5) {
- const dog = new Dog("Beagle", "Brązowy", "3 lata");
- dog.initialize();
- }
- }</script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement