Note that there are some explanatory texts on larger screens.

plurals
  1. POwhen I click submit, it goes straight onto another page
    text
    copied!<p>My form submits to another page when I do not want it to. The current page is known as create_session.php</p> <p>I want the form to submit if all of the validation and the postback is met and even after that the user needs to click "Ok" when the confirmation box appears. Except this never happens. When the user clicks on the submit button, it takes the user straight to another page "QandATable.php", it doesn't care about about validation(), the postback() and the confirmation box doesn't appear.</p> <p>So what I want to know is that when the user clicks on the submit button, how can I get it so that it checks for the validation(), postback() and confirmation box (showConfirm()) before even going onto the next page.</p> <p>I believe the problem is the submit button and the form action. Below is the form:</p> <pre><code> &lt;form action="QandATable.php" method="post" id="sessionForm"&gt; &lt;p&gt;&lt;input type="text" id="txtMarks" name="textMarks" onkeypress="return isNumberKey(event)" maxlength="5" /&gt;&lt;br/&gt;&lt;span id="marksAlert"&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Room:&lt;/strong&gt; &lt;input type="text" id="room" name="roomChosen" value="&lt;?php echo $roomChosen; ?&gt;" /&gt; &lt;br/&gt;&lt;span id="roomAlert"&gt;&lt;/span&gt;&lt;/p&gt; &lt;!-- Enter Room here--&gt; &lt;p&gt;&lt;input class="questionBtn" type="submit" value="Prepare Questions" name="prequestion" onClick="myClickHandler()"/&gt;&lt;/p&gt; &lt;/form&gt; </code></pre> <p>Below is the javascript click handler where it checks for the validation(), postback() and then if both of those met then it will showConfirm().</p> <pre><code>function myClickHandler(){ if(validation()){ postback(function(message) { if (message == "") showConfirm(); }); } } </code></pre>
 

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