StefiIOE

lab 4.3

Feb 10th, 2020
198
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.   <meta charset="UTF-8">
  5.   <title>zadaca3</title>
  6.   <style>
  7.     #gore {
  8.       margin-left: 80px;
  9.       padding-bottom: 10px;
  10.     }
  11.  
  12.     button {
  13.       margin-top: 10px;
  14.       margin-left: 133px;
  15.     }
  16.     #containter{
  17.       display: inline-block;
  18.       margin-left: 35%;
  19.       margin-top: 25%;
  20.     }
  21.   </style>
  22.  
  23. </head>
  24. <body>
  25. <div id="containter">
  26.   <div id="gore">
  27.     <input type="radio" value="color" name="selektor" checked>Color
  28.     <input type="radio" value="image" name="selektor">Image<br>
  29.   </div>
  30.   <div>
  31.     <label>Value: </label><input type="text" id="vid"><br>
  32.     <button onclick="promeni();">Промени</button>
  33.   </div>
  34. </div>
  35. </body>
  36. </html>
  37.   <script>
  38.     function promeni() {
  39.       document.body.style.backgroundImage = "";
  40.       var radios = document.getElementsByName('selektor');
  41.       var input = document.getElementById('vid').value;
  42.       if (radios[0].checked == true) {
  43.         document.body.style.backgroundColor = input;
  44.       }
  45.       else if (radios[1].checked == true) {
  46.         document.body.style.backgroundImage = "url('"+input+"')";
  47.       }
  48.     }
  49.   </script>
RAW Paste Data