Note that there are some explanatory texts on larger screens.

plurals
  1. POLoading a thank you pop up div on form submit
    primarykey
    data
    text
    <p>I am having issues loading a jQuery modal window upon submit. </p> <p>I want a div to load upon submit to thank the user for entering a competition. The div opens fine if I add an a href like: <code>&lt;a href="#dialog" name="modal"&gt;click here"&lt;/a&gt;</code> </p> <p>However I can't seem to make this popup once submit. Am I doing something wrong!?</p> <p>This is my form php code:</p> <pre><code>&lt;?php if($_POST['formSubmit'] == "Submit") { $errorMessage = ""; if(empty($_POST['formName'])) { $errorMessage .= "&lt;li&gt;You forgot to enter your name&lt;/li&gt;"; } if(empty($_POST['formTown'])) { $errorMessage .= "&lt;li&gt;You forgot to enter your town&lt;/li&gt;"; } $varName = $_POST['formName']; $varTown = $_POST['formTown']; $varAge = $_POST['formAge']; $varEmail = $_POST['formEmail']; $varOne = $_POST['hidden-one']; $varTwo = $_POST['hidden-two']; $varThree = $_POST['hidden-three']; $varFour = $_POST['hidden-four']; $varFive = $_POST['hidden-five']; if(empty($errorMessage)) { $fs = fopen("mydata.csv","a"); fwrite($fs,$varName . ", " . $varTown . ", " . $varAge . ", " . $varEmail . ", " . $varOne . $varTwo . $varThree . $varFour . $varFive . "\n"); fclose($fs); header("Location: #dialog"); exit; } } ?&gt; </code></pre> <p>This is the jquery code:</p> <pre><code>&lt;script&gt; $(document).ready(function() { //select all the a tag with name equal to modal $('a[name=modal]').click(function(e) { //Cancel the link behavior e.preventDefault(); //Get the A tag var id = $(this).attr('href'); //Get the screen height and width var maskHeight = $(document).height(); var maskWidth = $(window).width(); //Set heigth and width to mask to fill up the whole screen $('#mask').css({'width':maskWidth,'height':maskHeight}); //transition effect $('#mask').fadeIn(1000); $('#mask').fadeTo("slow",0.8); //Get the window height and width var winH = $(window).height(); var winW = $(window).width(); //Set the popup window to center $(id).css('top', winH/2-$(id).height()/2); $(id).css('left', winW/2-$(id).width()/2); //transition effect $(id).fadeIn(2000); }); //if close button is clicked $('.window .close').click(function (e) { //Cancel the link behavior e.preventDefault(); $('#mask').hide(); $('.window').hide(); }); //if mask is clicked $('#mask').click(function () { $(this).hide(); $('.window').hide(); }); }); &lt;/script&gt; </code></pre> <p>This is my html:</p> <pre><code>&lt;form action="enter.php" method="post" target="_self"&gt; &lt;input class="submit" type="submit" name="formSubmit" value="Submit"&gt; &lt;/form&gt; &lt;div id="boxes"&gt; &lt;div id="dialog" class="window"&gt; &lt;p&gt;Modal content here&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;!-- Mask to cover the whole screen --&gt; &lt;div id="mask"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre>
    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. This table or related slice is empty.
    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