Spaces:
Running
Running
Update index.html
Browse files- index.html +16 -1
index.html
CHANGED
@@ -28,4 +28,19 @@
|
|
28 |
// Qui andrà il JavaScript
|
29 |
</script>
|
30 |
</body>
|
31 |
-
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
// Qui andrà il JavaScript
|
29 |
</script>
|
30 |
</body>
|
31 |
+
</html>
|
32 |
+
|
33 |
+
document.getElementById('randomSelectButton').addEventListener('click', function() {
|
34 |
+
var results = [];
|
35 |
+
for (var i = 1; i <= 5; i++) {
|
36 |
+
var categoryInput = document.getElementById('category' + i).value;
|
37 |
+
if (categoryInput) {
|
38 |
+
var options = categoryInput.split(',');
|
39 |
+
var randomIndex = Math.floor(Math.random() * options.length);
|
40 |
+
results.push(options[randomIndex].trim());
|
41 |
+
} else {
|
42 |
+
results.push('Nessuna opzione per la Categoria ' + i);
|
43 |
+
}
|
44 |
+
}
|
45 |
+
document.getElementById('results').innerHTML = 'Risultati: <br>' + results.join('<br>');
|
46 |
+
});
|