Skip to content

Commit

Permalink
12345
Browse files Browse the repository at this point in the history
  • Loading branch information
ROHITBANSAL65 committed Oct 23, 2024
1 parent b2760e9 commit 7ce22c5
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions client/pricing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
document.addEventListener('DOMContentLoaded', function () {
// Toggle between Monthly and Yearly Pricing
const toggleSwitch = document.querySelector('#toggle-pricing');
const priceElements = document.querySelectorAll('.price');

toggleSwitch.addEventListener('change', function () {
const isYearly = toggleSwitch.checked;

priceElements.forEach(priceElement => {
const monthlyPrice = priceElement.getAttribute('data-monthly');
const yearlyPrice = priceElement.getAttribute('data-yearly');

if (isYearly) {
priceElement.innerText = yearlyPrice;
} else {
priceElement.innerText = monthlyPrice;
}
});
});

// Handle Plan Selection
const buttons = document.querySelectorAll('.btn-select');
buttons.forEach(button => {
button.addEventListener('click', function () {
const selectedPlan = this.closest('.pricing-card').querySelector('h2').innerText;
alert('You have selected the ' + selectedPlan + ' plan.');
});
});

// Optional: Add selected plan to cart or process payment (custom logic can go here)
function addToCart(plan) {
console.log(plan + ' added to cart.');
// Add additional logic here for payment processing or cart functionality
}
});

0 comments on commit 7ce22c5

Please sign in to comment.