Skip to content

Instantly share code, notes, and snippets.

@Aman-k346
Created May 2, 2023 14:33
Show Gist options
  • Save Aman-k346/66d3b9e7d58019d40e9f5469e65a9dbd to your computer and use it in GitHub Desktop.
Save Aman-k346/66d3b9e7d58019d40e9f5469e65a9dbd to your computer and use it in GitHub Desktop.
let increaseBtnSauna = document.querySelectorAll('.increase.ti-plus')[1];
let decreaseBtnSauna = document.querySelectorAll('.decrease.ti-minus')[1];
let saunaTowelService = document.querySelector('#extra-service-sauna-handdoek');
let numAdults = document.querySelector('[name="num_adults"]').value;
let saunaCount = 1;
let saunaMaxCount = 6;
let saunaMinCount = 0;
let bathrobeCount = 1;
let bathrobeMaxCount = 6;
let bathrobeMinCount = 0;
let increaseBtnBathrobe = document.querySelectorAll('.increase.ti-plus')[2];
let decreaseBtnBathrobe = document.querySelectorAll('.decrease.ti-minus')[2];
let bathrobeService = document.querySelector('#extra-service-badjas');
increaseBtnSauna.addEventListener('click', () => {
numAdults = document.querySelector('[name="num_adults"]').value;
if (saunaCount < saunaMaxCount && numAdults > 4) {
saunaCount++;
saunaTowelService.innerText = saunaCount;
console.log(`Sauna towel count increased to ${saunaCount}`);
}
});
decreaseBtnSauna.addEventListener('click', () => {
numAdults = document.querySelector('[name="num_adults"]').value;
if (saunaCount > saunaMinCount) {
saunaCount--;
saunaTowelService.innerText = saunaCount;
console.log(`Sauna towel count decreased to ${saunaCount}`);
}
});
increaseBtnBathrobe.addEventListener('click', () => {
numAdults = document.querySelector('[name="num_adults"]').value;
if (bathrobeCount < bathrobeMaxCount && numAdults > 4) {
bathrobeCount++;
bathrobeService.innerText = bathrobeCount;
console.log(`Bathrobe count increased to ${bathrobeCount}`);
}
});
decreaseBtnBathrobe.addEventListener('click', () => {
numAdults = document.querySelector('[name="num_adults"]').value;
if (bathrobeCount > bathrobeMinCount && numAdults > 4) {
bathrobeCount--;
bathrobeService.innerText = bathrobeCount;
console.log(`Bathrobe count decreased to ${bathrobeCount}`);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment