You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
640 B
JavaScript
13 lines
640 B
JavaScript
// TO CHANGE THE PRICE BASED ON THE CHOSEN CYCLE FROM THE SELECT TAG
|
|
function updateCyclePrice() {
|
|
var selectedOption = document.getElementById('cycle').options[document.getElementById('cycle').selectedIndex];
|
|
var cyclePrice = parseFloat(selectedOption.getAttribute('data-cycle-price'));
|
|
document.getElementById('cyclePrice').textContent = cyclePrice.toFixed(2);
|
|
}
|
|
|
|
document.getElementById('cycle').addEventListener('change', updateCyclePrice);
|
|
|
|
// Trigger the change event when the page loads to display the cycle price of the selected option by default
|
|
window.addEventListener('load', function () {
|
|
updateCyclePrice();
|
|
}); |