I have buttons similar to the one here A3. I want to check the availability of the seat from my database and do accordingly in the if loop.. but none of my functions below the firebase reference is working
My database is
My web (app) | Seats(node) | Status (node) | A1 - available (value) A2 - available (value) A3 - available (value) A4 - available (value)
And my js script is
function A3(){
var newseat = document.getElementById("A3");
var firebaseStatusRef = firebase.database().ref().child("Status");
var firebaseSeatStatusRef = firebaseStatusRef.child("A3");
firebaseSeatStatusRef.on('child_added', snap => {
var seatStatus = snap.val();
});
if (firebaseSeatStatusRef=="available") {
newseat.className="booked-seat";
newseat.setAttribute("class" , "booked-seat");
firebaseStatusRef.child("A3").set("booked");
var fill = newseat.value;
document.getElementById("fill").value += fill + " ";
Seat();
} else {
newseat.style.backgroundColor = 'seat';
newseat.setAttribute("class" , "seat");
var fill = newseat.value;
document.getElementById("fill").value -= fill + " ";
BookedSeat();
}
}
Aucun commentaire:
Enregistrer un commentaire