Загрузка...

Create a Ticket booking system with Google Forms and Sheets

This video demonstrate about how to create a ticket booking system with Google forms and Google sheets.

Here is the code used.
function onFormSubmit(e) {
const formData = e.namedValues;

const showTime = formData['Show time'][0];
const seatRow = formData['Seat Row'][0];
const seatNumber = parseInt(formData['Seat Number'][0]);

// Match exact time values
let sheetName;
if (showTime === '3:30 Show') {
sheetName = 'Show1_Map';
} else if (showTime === '6:30 Show') {
sheetName = 'Show2_Map';
} else {
Logger.log('Unknown show time: ' + showTime);
return; // Stop if the show time is unrecognized
}

const mapSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetName);
if (!mapSheet) {
Logger.log('Sheet not found: ' + sheetName);
return;
}

// Calculate row index (A = row 2), seatNumber = column B (2nd column)
const rowIndex = seatRow.charCodeAt(0) - 'A'.charCodeAt(0) + 2;
const colIndex = seatNumber + 1;

// Mark the seat as booked
const cell = mapSheet.getRange(rowIndex, colIndex);
cell.setValue('❌');
cell.setBackground('#ff9999'); // Red
}

Видео Create a Ticket booking system with Google Forms and Sheets канала Actics
Страницу в закладки Мои закладки
Все заметки Новая заметка Страницу в заметки