<form class="hero__form">
<label for="" class="label">
Дата заезда
<input name="arrive" type="date" class="input" id="arrive" required />
</label>
<label for="" class="label">
Дата выезда
<input name="departure" id="departure" type="date" class="input" required />
</label>
<label for="" class="label">
Количество гостей
<div class="guestInput__wrapper">
<input
name="guests"
type="number"
step="1"
min="1"
class="input"
required
id="guestsInput"
/>
</div>
</label>
<button class="button hero__form-button">Подобрать номер</button>
</form>
if (roomFiltersForm) {
guestsInput.addEventListener('input', (event) => {
const guests = event.target.value;
const departure = document.getElementById('departure');
const arrival = document.getElementById('arrival');
const bookingButton = document.querySelector('.hero__form-button');
const firstDate = new Date(arrival);
const secondDate = new Date(departure);
// Вычисляем разницу между датами в миллисекундах
const timeDifference = firstDate.getTime() - secondDate.getTime() + (1000 * 3600 * 24);
// Преобразуем разницу в дни
const day = timeDifference / (1000 * 3600 * 24);
window.open("booking.php?gosti=" + guests + "&day=" + day, '_blank'); // Открываем новое окно при вводе значения
});
}