views:

166

answers:

2

Hi all

I have a question regarding Facebox. When I click a certain link on my page, the Facebox modal window opens just fine. But inside this modal window I'd like to have a form that users can submit. When the users click the submit-button, the whole page refreshes, and my Facebox-window is closed. This makes sense to me, but I'd like it to work differently.

I want to give the user a confirmation, inside of the modal window, after they have submitted the form. So when a user clicks the submit-button, a confirmation should be showed inside og the modal-window. Anybody know if this is possible?

I hope that you understand my question :)

Best regards

Kim Andersen

A: 

You need to change your form to use AJAX POST instead of standard HTML POST request. Here's a simple tutorial that shows how to do AJAX form with jQuery.

Franci Penov
A: 
  <form action='whateveryouhave.php' method='POST' id='myform' ><!--notice the form id-->
  <!-- your input and form stuff here just as you have it-->
  <a href='javascript:void(0);' onclick="submitFacebox">
  Submit in facebox instead of whole window
  </a>

  <script type='text/javascript'>
  function submitFacebox() {
      jQuery.post(jQuery('#myform').attr('action'), jQuery('#myform').serialize());
  }
  </script>
Neo