I need to initialise PHP Variable inside javascript??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Prajwal GN
    New Member
    • Dec 2010
    • 2

    I need to initialise PHP Variable inside javascript??

    The below code is an javascript funution . I need to initialise PHP variable in the else part of it pls do help me



    Code:
    function validate(){
    
       if(document.loginForm.vuser_login.value==""){
    
          alert("Login Name name cannot be empty");
          document.loginForm.vuser_login.focus();
          return false;
    
        }else if(document.loginForm.vuser_password.value==""){
    
          alert("Password cannot be empty");
          document.loginForm.vuser_password.focus();
          return false;
    
        }else{
    //here i need to initialise ($act) PHP variable
        return true;
    
        }
    
    }
    Last edited by Dormilich; Dec 7 '10, 04:16 PM. Reason: please use [CODE] [/CODE] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    I need to initialise PHP variable in the else part of it
    you can’t. PHP is executed on the server while JavaScript is executed on the client (the browser). that is, when JavaScript is executed, PHP already finished and is not working any more.

    Comment

    • dlite922
      Recognized Expert Top Contributor
      • Dec 2007
      • 1586

      #3
      For More Info: http://www.php.net/manual/en/faq.htm...cript-variable

      Dan

      Comment

      Working...