Wedding Invitation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rsvp-modal.blade.php 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <dialog id="rsvp" class="modal">
  2. <div class="modal-box w-11/12 max-w-5xl">
  3. <h3 class="text-lg font-bold">RSVP</h3>
  4. <form id="rsvpForm">
  5. @csrf
  6. <label class="form-control w-full max-w-xs">
  7. <div class="label">
  8. <span class="label-text">Nama</span>
  9. </div>
  10. <input type="text" name="name" placeholder="Taip disini" class="input input-bordered input-sm input-accent w-full max-w-xs" />
  11. </label>
  12. <label class="form-control w-full max-w-xs">
  13. <div class="label">
  14. <span class="label-text">Bilangan</span>
  15. </div>
  16. <input type="number" name="member" placeholder="Taip disini" class="input input-bordered input-sm input-accent w-full max-w-xs" />
  17. </label>
  18. <label class="form-control w-full max-w-xs">
  19. <div class="label">
  20. <span class="label-text">No. Tel</span>
  21. </div>
  22. <input type="number" name="phone" placeholder="Taip disini" class="input input-bordered input-sm input-accent w-full max-w-xs" />
  23. </label>
  24. </form>
  25. <div class="modal-action">
  26. <form method="dialog" id="closeRsvpForm"></form>
  27. <button type="button" class="btn bg-babybluedark" id="submitRsvpForm">Hantar</button>
  28. <button type="button" class="btn" id="submitCloseRsvpForm">Tutup</button>
  29. </div>
  30. </div>
  31. </dialog>
  32. @push('script')
  33. <script>
  34. $(document).ready(function() {
  35. $('#submitCloseRsvpForm').click(function(e) {
  36. $('#closeRsvpForm').submit();
  37. });
  38. $('#submitRsvpForm').click(function(e) {
  39. e.preventDefault();
  40. var formData = $('#rsvpForm').serialize();
  41. $.ajax({
  42. url: '{{ route('rsvp.save') }}',
  43. type: 'POST',
  44. data: formData,
  45. success: function(response) {
  46. $('#closeRsvpForm').submit();
  47. $('#rsvpForm')[0].reset();
  48. var alertContainer = $('.alert-info');
  49. alertContainer.find('span').text(response.message); // Set message text
  50. alertContainer.fadeIn().removeClass('hidden'); // Show the alert
  51. setTimeout(function() {
  52. alertContainer.fadeOut().addClass('hidden'); // Hide the alert after 5 seconds
  53. }, 3000);
  54. },
  55. error: function(xhr, status, error) {
  56. console.error('Error submitting form:', error);
  57. }
  58. });
  59. });
  60. });
  61. </script>
  62. @endpush