Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First use thickbox's iframe feature to load the form in the thickbox. Make sure you have jquery and thickbox loaded by putting this in the HTML head of your document:</p> <pre><code>&lt;script type="text/javascript" src="/javascripts/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="/javascripts/thickbox.js"&gt;&lt;/script&gt; &lt;link href="/stylesheets/thickbox.css" rel="stylesheet" type="text/css" /&gt; </code></pre> <p>Then put a link on the page the loads the contact us form in the iframe:</p> <pre><code>&lt;a href="/contact_us_form.php?KeepThis=true&amp;TB_iframe=true&amp;height=400&amp;width=600&amp;modal=true" class="thickbox" title="Contact Us"&gt;Contact Us&lt;/a&gt; </code></pre> <p>Your form should have markup that has this basic structure:</p> <pre><code>&lt;div id="content"&gt; &lt;form id="contact_us" action="/contact_us.php" method="POST"&gt; ... &lt;/form&gt; &lt;/div&gt; </code></pre> <p>Now use jQuery to your form via AJAX. Put this in the head of the HTML document:</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery(function($){ $('#contact_us').submit(function(){ $.post($(this).attr('action'), function(html) { $('#content').html(html) }) return false }) }) &lt;/script&gt; </code></pre> <p>What this does is:</p> <ol> <li><p>Adds a function to the form to be called when the form is submitted. It returns false to prevent the default behavior of a form submitting from happen.</p></li> <li><p>This submit function will do an AJAX post, using the action of the form, which you set to <code>contact_us.php</code>.</p></li> <li><p>Finally, this will take whatever content <code>contact_us.php</code> returns and replace the content of the div with the id content with that.</p></li> </ol> <p>So make your <code>contact_us.php</code> script actually send the email or create a database record, whatever it does, and then have it return this HTML:</p> <pre><code>&lt;p&gt;Thank you for your submission!&lt;/p&gt; &lt;p&gt;&lt;a href="#" onclick="window.parent.tb_remove(); return false"&gt;Continue&lt;/a&gt; </code></pre> <p>Obviously this can be anything you want, whatever message you want the end user to see. The link shows you how to make the thickbox window go away.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload