Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form id="ov-donation-form">
- <input type="hidden" name="amount" id="selected-amount" value="">
- <div id="ov-group-buttons">
- <button type="button" class="ov-donation-button" data-amount="5">$5</button>
- <button type="button" class="ov-donation-button" data-amount="50">$50</button>
- <button type="button" class="ov-donation-button" data-amount="100">$100</button>
- <button type="button" class="ov-donation-button" data-amount="200">$200</button>
- <button type="button" class="ov-donation-button" data-amount="500">$500</button>
- <button type="button" class="ov-donation-button" data-amount="800">$800</button>
- <button type="button" class="ov-donation-button" data-amount="1000">$1000</button>
- </div>
- <label>Ingresa otra cantidad:</label>
- <input type="number" name="custom-amount" id="custom-amount" placeholder="Cantidad personalizada">
- <button type="button" id="ov-donate-button">Donar</button>
- </form>
- <script>
- document.getElementById('ov-donate-button').addEventListener('click', () => {
- const selectedAmount = document.getElementById('selected-amount').value;
- const mensajeWhatsApp = `¡Hola! Quiero donar $${selectedAmount} MXN para apoyar la causa.`;
- const whatsappURL = `https://wa.me/529511234567?text=${encodeURIComponent(mensajeWhatsApp)}`;
- window.open(whatsappURL, '_blank');
- });
- document.querySelectorAll('.ov-donation-button').forEach(button => {
- button.addEventListener('click', function() {
- const selectedAmount = this.getAttribute('data-amount');
- document.getElementById('selected-amount').value = selectedAmount;
- document.getElementById('custom-amount').value = '';
- document.querySelectorAll('.ov-donation-button').forEach(btn => {
- btn.classList.remove('selected');
- });
- this.classList.add('selected');
- document.getElementById('ov-donate-button').innerText = 'Donar $' + selectedAmount + ' MXN';
- });
- });
- document.getElementById('custom-amount').addEventListener('input', function() {
- const customAmount = this.value;
- document.getElementById('selected-amount').value = customAmount;
- document.querySelectorAll('.ov-donation-button').forEach(btn => {
- btn.classList.remove('selected');
- });
- document.getElementById('ov-donate-button').innerText = 'Donar $' + customAmount + ' MXN';
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement