Question: 1. the php file (alright.php) Movie Seat Booking Pick a movie: Avengers: Endgame (RM10.5) Frozen (RM12) N/A Selected Occupied A1 A2 A3 A4 B1 B2

1. the php file (alright.php)

Movie Seat Booking

  • N/A
  • Selected
  • Occupied

A1
A2

A3
A4

B1
B2

B3
B4

C1
C2

C3
C4

D1
D2

D3
D4

E1
E2

E3
E4

E5
E6

F1
F2

F3
F4

G1
G2

G3
G4

H1
H2

H3
H4

You have selected 0 seats.

Adult (age 20 - 70)

Your order total is: RM

2.PHP file (next.php)

Checkout

CART

Price //this part is the one i meant. i want to fetch 'harga' from alright.php to here thanksin advance

Food & Drinks RM5

Total Seat RM8

Seat D4 RM2


Total RM30

Payment

Checkout

« Previous

3.java (alright.js)

const container = document.querySelector('.container');

const seats = document.querySelectorAll('.row .seat:not(.occupied)');

const count = document.getElementById('count');

const duduk = document.querySelectorAll('.row .seat #id');

const movieSelect = document.getElementById('movie');

populateUI();

let ticketPrice = +movieSelect.value;

// Save selected movie index and price

function setMovieData(movieIndex, moviePrice) {

localStorage.setItem('selectedMovieIndex', movieIndex);

localStorage.setItem('selectedMoviePrice', moviePrice);

}

// Update total and count

function updateSelectedCount() {

const selectedSeats = document.querySelectorAll('.row .seat.selected');

const seatsIndex = [...selectedSeats].map(seat => [...seats].indexOf(seat));

localStorage.setItem('selectedSeats', JSON.stringify(seatsIndex));

const selectedSeatsCount = selectedSeats.length;

count.innerText = selectedSeatsCount;

total.innerText = selectedSeatsCount * ticketPrice;

setMovieData(movieSelect.selectedIndex, movieSelect.value);

}

// Get data from localstorage and populate UI

function populateUI() {

const selectedSeats = JSON.parse(localStorage.getItem('selectedSeats'));

if (selectedSeats !== null && selectedSeats.length > 0) {

seats.forEach((seat, index) => {

if (selectedSeats.indexOf(index) > -1) {

seat.classList.add('selected');

}

});

}

const selectedMovieIndex = localStorage.getItem('selectedMovieIndex');

if (selectedMovieIndex !== null) {

movieSelect.selectedIndex = selectedMovieIndex;

}

}

// Movie select event

movieSelect.addEventListener('change', e => {

ticketPrice = +e.target.value;

setMovieData(e.target.selectedIndex, e.target.value);

updateSelectedCount();

});

// Seat click event

container.addEventListener('click', e => {

if (

e.target.classList.contains('seat') &&

!e.target.classList.contains('occupied')

) {

e.target.classList.toggle('selected');

updateSelectedCount();

}

});

// Initial count and total set

updateSelectedCount();

my problem is, i cannot fetch data from alright.php to next.php. how to solve this? i want fetch "harga" (which mean total) in alright.php(the 1st code) to next.php(the2nd code).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!