Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - <!DOCTYPE html>
 - <html lang="it-IT">
 - <head>
 - <meta charset="UTF-8">
 - rel="stylesheet"
 - >
 - <style>
 - label {font-weight: bold; color: blue;}
 - #gamesPosseduti, input+button {width: 50px;}
 - table, td {border: 1px solid blue;}
 - td {width: 50px; height: 30px;}
 - </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;
 - if (true)
 - {
 - if (false)
 - {
 - }
 - else
 - {
 - if (progressivo==7) continue;
 - if (true)
 - {
 - if (progressivo>12) break;
 - }
 - else
 - {
 - }
 - }
 - }
 - //altre istruzioni
 - elenco.appendChild(nuovaOption);
 - }
 - }
 - </script>
 - <table>
 - <script>
 - //i cicli oltre a poter contenere strutture selettive possono
 - //contenere altri cicli (anche di tipi diversi)
 - for (let numero_riga=0; numero_riga<10; numero_riga++)
 - {
 - document.write("<tr>");
 - for (let numero_colonna=0; numero_colonna<4; numero_colonna++)
 - document.write("<td> </td>")
 - document.write("</tr>");
 - }
 - let numero_positivo=0;
 - for (;numero_positivo<=0;) numero_positivo = parseInt(prompt("inserire un numero maggiore di 0"));
 - // {
 - // numero_positivo = parseInt(prompt("inserire un numero maggiore di 0"));
 - // // if (numero_positivo<=0)
 - // // alert("sbagliato, riprova");
 - // // else
 - // // break;
 - // }
 - </script>
 - </table>
 - </body>
 - </html>
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment