function generateQRCode() {
    // Retrieve the values from the input fields
    const name = document.getElementById('name').value;
    const ticketId = document.getElementById('ticket_id').value;
    const eventName = document.getElementById('event_name').value;
    const checkInTime = document.getElementById('check_in_time').value;

    // Make sure all fields are filled
    if (!name || !ticketId || !eventName || !checkInTime) {
        alert("Please fill in all fields.");
        return;
    }

    // Format the event information into a string
    const eventInfo = `Name: ${name}, Ticket ID: ${ticketId}, Event: ${eventName}, Check-in Time: ${checkInTime}`;

    // Clear any previous QR code
    document.getElementById('qrCodeContainer').innerHTML = '';

    // Generate the QR code
    QRCode.toCanvas(document.getElementById('qrCodeContainer'), eventInfo, function (error) {
        if (error) {
            console.error(error);
        } else {
            console.log('QR code generated successfully!');
        }
    });
}