Scratch

Number Selection Game

Welcome to the Number Selection Game

Select 8 numbers from the ticket below:

document.addEventListener('DOMContentLoaded', function() { const numberChoices = document.getElementById('numberChoices'); const submissionMessage = document.getElementById('submissionMessage'); // Create 30 number choices for (let i = 1; i <= 30; i++) { const checkbox = document.createElement('input'); checkbox.type = 'checkbox'; checkbox.id = 'num' + i; checkbox.name = 'numbers'; checkbox.value = i; const label = document.createElement('label'); label.htmlFor = 'num' + i; label.appendChild(document.createTextNode(i)); numberChoices.appendChild(checkbox); numberChoices.appendChild(label); } // Handle form submission document.getElementById('numberForm').addEventListener('submit', function(event) { event.preventDefault(); const selectedNumbers = document.querySelectorAll('input[name="numbers"]:checked'); if (selectedNumbers.length === 8) { submissionMessage.innerHTML = 'You have successfully submitted your ticket.
Winning tickets will be drawn on: Every Saturday of the week.'; } else { submissionMessage.innerHTML = 'Please select exactly 8 numbers.'; } }); });

Comments

Popular posts from this blog