Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="it-IT">
- <head>
- <meta charset="UTF-8">
- <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.2/dist/css/bootstrap.min.css"
- rel="stylesheet"
- >
- <style>
- label {font-weight: bold; color: blue;}
- #gamesPosseduti, input+button {width: 50px;}
- </style>
- <title>CICLI</title>
- </head>
- <body>
- <div class="container">
- <form id="form">
- <div class="mb-3">
- <label for="cognome" class="form-label">Cognome</label>
- <input type="text" class="form-control bg-info bg-opacity-25" id="cognome">
- </div>
- <div class="mb-3">
- <label for="games_posseduti" class="form-label">N. games? </label>
- <input type="text" class="form-control bg-info bg-opacity-25" id="gamesPosseduti">
- <button type="button" id="go">GO</button>
- </div>
- </form>
- </div>
- <script>
- //otteniamo un riferimento al bottone nel DOM
- let rifBottone = document.querySelector("#go");
- rifBottone.addEventListener("click", generaTextBox);
- function generaTextBox()
- {
- let numeroGames =
- parseInt(document.querySelector("#gamesPosseduti").value);
- for (let contaTextBox=1; contaTextBox<=numeroGames; contaTextBox++)
- {
- let nuovoInput = document.createElement('input');
- nuovoInput.classList="form-control bg-info bg-opacity-25";
- form.appendChild(nuovoInput);
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement