01.Hotel Reservation от JS Advanced Retake Exam - 7 December 2022
Здравейте, получавам 76/100, в последнача част на кода при "verification" не ми изписва статусите "Confirmed" или "Canceled".
Някой може ли да ми помогне ?
Благодаря :)
задача: https://judge.softuni.org/Contests/Practice/Index/3732#0
код:
function solve() {
let fields = Array.from(document.querySelectorAll('input')).slice(0, 5)
let nextBtn = document.querySelector('#next-btn')
let infoSection = document.querySelector('.info-list')
let confirmSection = document.querySelector('.confirm-list')
let verification = document.getElementById('verification');
nextBtn.addEventListener("click", onClick);
function onClick(e) {
e.preventDefault();
let[firstName, lastName, dateIn, dateOut, count] = fields
if(!firstName.value || !lastName.value || !dateIn.value
|| !dateOut.value || !count.value) return
infoSection.innerHTML = `<li>reservation-content
<article>
<h3>Name: ${firstName.value} ${lastName.value}</h3>
<p1>From date: ${dateIn.value}</p1>
<p2>To date: ${dateOut.value}</p2>
<p3>For ${count.value} people</p3>
</article>
<button class="edit-btn">Edit</button>
<button class="continue-btn">Continue</button>
</li>
`
let editFirstName = firstName.value;
let editLastName = lastName.value;
let editDateIn = dateIn.value;
let editDateOut = dateOut.value;
let editcount = count.value;
firstName.value = "";
lastName.value = "";
dateIn.value = "";
dateOut.value = "";
count.value = "";
buttonsState(true)
document.querySelector('.edit-btn').addEventListener('click', onEdit)
function onEdit(){
firstName.value = editFirstName;
lastName.value = editLastName;
dateIn.value = editDateIn;
dateOut.value = editDateOut;
count.value = editcount;
buttonsState(false)
infoSection.innerHTML = ''
}
function buttonsState(nextDisabled = true){
if(nextDisabled){
nextBtn.disabled = true
document.querySelector('.edit-btn').disabled = false
document.querySelector('.continue-btn').disabled = false
} else {
nextBtn.disabled = false
document.querySelector('.edit-btn').disabled = true
document.querySelector('.continue-btn').disabled = true
}
}
document.querySelector('.continue-btn').addEventListener('click', onContinue)
function onContinue(){
confirmSection.innerHTML = `<li>reservation-content
<article>
<h3>Name: ${editFirstName} ${lastName.value}</h3>
<p1>From date: ${editDateIn}</p1>
<p2>To date: ${editDateOut}</p2>
<p3>For ${editcount} people</p3>
</article>
<button class="confirm-btn">Confirm</button>
<button class="cancel-btn">Cancel</button>
</li>
`
infoSection.innerHTML = ''
document.querySelector('.confirm-btn').addEventListener('click', onConfirm);
function onConfirm() {
confirmSection.innerHTML = ''
buttonsState(false)
verification.setAttribute('class', 'reservation-confirmed');
verification.textContent = 'Confirmed.';
}
document.querySelector('.cancel-btn').addEventListener('click',onCancel);
function onCancel() {
confirmSection.innerHTML = ''
buttonsState(false)
verification.setAttribute('class', 'reservation-cancelled');
verification.textContent = 'Cancelled.';
}
}
}
}
Благодаря ! Наистина някои много тъпи грешки ще внимавам повече :))))