Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble with javascript if statement
    primarykey
    data
    text
    <p>Ok, I'm making a login and registration panel with jquery and php. In short, if there are errors with the registration it sets a few form errors, redirects back to the registration page, the javascript detects there are errors with the use of a php variable and forces the slider to show itself.</p> <p>The working code: Above the doc type <code>$errors = $form-&gt;num_errors;</code> and the whole <code>$errors</code> routine works fine.</p> <p>My problem is that I also have a verification that the form was submitted successfully. It uses</p> <pre><code>if(isset($_SESSION['regsuccess'])){ $success = 1; } else { $success = 0; } </code></pre> <p>to set the <code>$success</code> variable. The crazy thing here is that this doesn't work using the same routine as the <code>$error</code> variable. I know the <code>$success</code> conditional is working correctly as I have an it echoed out further down the page.</p> <p>jQuery slide script:</p> <pre><code>$(document).ready(function() { var num_errors = "&lt;?php $errors; ?&gt;"; var form_success = "&lt;?php $success; ?&gt;"; // Expand Panel $("#open").click(function(){ $("div#panel").slideDown("slow"); }); // Collapse Panel $("#close").click(function(){ $("div#panel").slideUp("slow"); }); // Switch buttons from "Log In | Register" to "Close Panel" on click $("#toggle a").click(function () { $("#toggle a").toggle(); }); //this part works if(errors&gt;0){ $("div#panel").slideDown(); $("#toggle a").toggle(); } //this part doesn't if(form_success&gt;0){ $("div#panel").slideDown(); $("#toggle a").toggle(); } }); </code></pre> <p>The demo page is here <code>http://demo.ivannovak.com/danlogin/index.php</code></p> <p>Suggestions would be appreciated, thanks!</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. 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