Advertisement
oscarviedma

Código Formulario Donaciones OV

Feb 8th, 2024
406
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.39 KB | None | 0 0
  1. <form id="ov-donation-form" action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_blank">
  2. <input type="hidden" name="cmd" value="_donations">
  3. <input type="hidden" name="business" value="tu_correo_paypal">
  4. <input type="hidden" name="return" value="url_pagina_gracias">
  5. <!-- <input type="hidden" name="currency_code" value="USD"> -->
  6. <label>Selecciona la cantidad a donar:</label>
  7. <div id="ov-group-buttons">
  8. <button type="button" class="ov-donation-button" data-amount="5">$5</button>
  9. <button type="button" class="ov-donation-button" data-amount="50">$50</button>
  10. <button type="button" class="ov-donation-button" data-amount="100">$100</button>
  11. <button type="button" class="ov-donation-button" data-amount="200">$200</button>
  12. <button type="button" class="ov-donation-button" data-amount="500">$500</button>
  13. <button type="button" class="ov-donation-button" data-amount="800">$800</button>
  14. <button type="button" class="ov-donation-button" data-amount="1000">$1000</button>
  15. </div>
  16. <label>Ingresa otra cantidad:</label>
  17. <input type="number" name="custom-amount" id="custom-amount" placeholder="Cantidad personalizada">
  18. <input type="hidden" name="amount" id="selected-amount" value="">
  19. <button type="submit" id="ov-donate-button">Donar</button>
  20. </form>
  21.  
  22. <script>
  23. document.querySelectorAll('.ov-donation-button').forEach(button => {
  24. button.addEventListener('click', function() {
  25. var selectedAmount = this.getAttribute('data-amount');
  26. document.getElementById('selected-amount').value = selectedAmount;
  27. document.getElementById('custom-amount').value = '';
  28. document.querySelectorAll('.ov-donation-button').forEach(btn => {
  29. btn.classList.remove('selected');
  30. });
  31. this.classList.add('selected');
  32.  
  33. document.getElementById('ov-donate-button').innerText = 'Donar $' + selectedAmount + ' MXN';
  34. });
  35. });
  36.  
  37. document.getElementById('custom-amount').addEventListener('input', function() {
  38. var customAmount = this.value;
  39. document.getElementById('selected-amount').value = customAmount;
  40. document.querySelectorAll('.ov-donation-button').forEach(btn => {
  41. btn.classList.remove('selected');
  42. });
  43.  
  44. document.getElementById('ov-donate-button').innerText = 'Donar $' + customAmount + ' MXN';
  45. });
  46. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement