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">
- <button type="button" id="go">GO</button>
- <select id="anno">
- </select>
- </form>
- </div>
- <script>
- //otteniamo un riferimento al bottone nel DOM
- let rifBottone = document.querySelector("#go");
- rifBottone.addEventListener("click", generaDropDownlist);
- function generaDropDownlist()
- {
- let annoPartenza = prompt("Da che anno parto? ");
- let annoArrivo = new Date().getFullYear();
- let elenco = document.querySelector("#anno");
- for (let anno=annoArrivo, progressivo=1 ;anno>=annoPartenza; anno--, progressivo++)
- {
- //<option value="1">2022</option>
- let nuovaOption = document.createElement('option');
- nuovaOption.innerText = anno;
- nuovaOption.value=progressivo;
- elenco.appendChild(nuovaOption);
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement