One of the challenges I'm facing involves a function that calculates the total cost of tickets based on user selection from a dropdown list. The price per ticket is stored in my database and retrieved when needed.
The function itself is functional:
function quantityChange(selElem) {
//Get the selected value from the dropdown list
var quantity = $('#showQuantity option:selected').val();
//Retrieve ticket price from 'ticket' table
var ticket = parseInt(document.getElementById('ticketPriceHidden').value);
//Obtain venue information
var venue = document.getElementById('venuePlaceHidden').value;
//Multiply quantities to get total cost
var total = quantity * ticket;
document.getElementById('summary').innerHTML= 'You have chosen'+ ' ' + quantity + ' ' + 'tickets @' + ' ' + venue + ' = ' + ' ' + ' £' + total;
}
This function is triggered within a div labeled 'ticket'. Once the user views the calculated total and proceeds by clicking a 'continue' button, the 'ticket' div is hidden and replaced with a 'delivery' div to retain the result.
Now, I am faced with another challenge: I need to display the result of the quantityChange(selElem) function within a new div called 'summary'. Is there a way to achieve this?
Your assistance would be highly appreciated. Thank you.