SHARE
TWEET

Random Item

a guest Feb 14th, 2020 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <meta charset="utf-8">
  5.     <title>Random Item</title>
  6. </head>
  7. <body>
  8.     <form id="numberForm">
  9.         <p>Result is: <span id="result"></span></p>
  10.         <label>Enter Numbers</label>
  11.         <input type="text" name="number">
  12.         <br>
  13.         <button type="button">Click</button>
  14.     </form>
  15.     <script type="text/javascript">
  16.         const lines = [
  17.             "aco linija 1",
  18.             "alek linija 2",
  19.             "alek linija 3",
  20.             "pod kur mi se skri",
  21.             "marto linija 5",
  22.             "da te ebe cel svet",
  23.             "aco ima zhenska",
  24.             "aco ima csgo serveri"
  25.         ];
  26.  
  27.         let buttonSubmit = document.querySelector("#numberForm button");
  28.         buttonSubmit.onclick = function(){
  29.             let r = Math.floor(Math.random() * Math.floor(lines.length));
  30.             let inputNumber = parseInt(document.querySelector("#numberForm input").value);
  31.             let result = document.querySelector("#numberForm #result");
  32.             if(!isNaN(inputNumber)){
  33.                 if( inputNumber >= 14 && inputNumber <= 18){
  34.                     result.innerHTML = lines[r];
  35.                 }else{
  36.                     result.innerHTML = "Not between 14 and 18";
  37.                 }
  38.             }else{
  39.                 result.innerHTML = "Input is not a number!";
  40.             }
  41.         };
  42.     </script>
  43. </body>
  44. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top