diff --git a/pending_bookings.php b/pending_bookings.php index fbd0ed5..794b9e4 100644 --- a/pending_bookings.php +++ b/pending_bookings.php @@ -689,7 +689,14 @@ try { calendarGrid.querySelectorAll('.calendar-day').forEach(day => { day.classList.remove('selected'); }); - document.querySelector(`[data-date="${date}"]`).classList.add('selected'); + + // 找到当前日历中的日期元素 + const calendarDays = calendarGrid.querySelectorAll('.calendar-day'); + calendarDays.forEach(day => { + if (day.dataset.date === date) { + day.classList.add('selected'); + } + }); // 生成时间段 generateTimeSlots(submissionId, date); @@ -717,6 +724,7 @@ try { const slotDiv = document.createElement('div'); slotDiv.className = `time-slot ${isPast ? 'past' : ''} ${isBooked ? 'booked' : 'available'}`; slotDiv.textContent = timeString; + slotDiv.dataset.time = timeString; slotDiv.onclick = () => selectTimeSlot(submissionId, timeString); timeGrid.appendChild(slotDiv); @@ -763,7 +771,7 @@ try { slot.classList.remove('selected'); }); - const slotElement = timeGrid.querySelector(`[onclick="selectTimeSlot(${submissionId}, '${time}')"]`); + const slotElement = timeGrid.querySelector(`[data-time="${time}"]`); if (slotElement) { slotElement.classList.add('selected'); }