Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions