Advertisement
MatiGe

index

May 3rd, 2025
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 1.16 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.  
  4. <head>
  5.     <title>Code Generator</title>
  6.     <style>
  7.         body {
  8.             font-family: sans-serif;
  9.             text-align: center;
  10.         }
  11.  
  12.         #generatedCode {
  13.             font-size: 2em;
  14.             font-weight: bold;
  15.             margin-top: 20px;
  16.         }
  17.     </style>
  18. </head>
  19.  
  20. <body>
  21.     <h1>Your Secret Code</h1>
  22.     <div id="generatedCode"></div>
  23.     <button onclick="generateCode()">Generate New Code</button>
  24.  
  25.     <script>
  26.         function generateCode() {
  27.             const length = 8;
  28.             const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  29.             let code = '';
  30.             for (let i = 0; i < length; i++) {
  31.                code += characters.charAt(Math.floor(Math.random() * characters.length));
  32.            }
  33.            document.getElementById('generatedCode').innerText = code;
  34.            // You might want to store this code somewhere if you need server-side verification
  35.            console.log("Generated Code:", code);
  36.        }
  37.  
  38.        // Generate an initial code when the page loads
  39.        generateCode();
  40.    </script>
  41. </body>
  42.  
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement