Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts

    js reference to a PHP variable

    all,

    i have this code:
    Code:
    if (! $_POST["Name"] || ! $_POST["LName"] || ! $_POST["email"] || ! $_POST["phone"])
    {
       $Alert_Message = "Invalid Form";
    }
    i got a js script from another forum here on this site that looks like this, and does work well:
    Code:
    print <<<JSOUT
    <script type="text/javascript">
    	confirm("Form is INVALID");
        window.back();
    </script>
    JSOUT;
    exit;
    i have 4 different messages that i want to choose from to be displayed in the js script, and I want to store the message that i want to use in a PHP variable along the way. the variable is: $Alert_Message . i am trying to do this with my confirm() function in js:
    Code:
    confirm($Alert_Message);
    the code is not registering, so something is obviously wrong. can i reference PHP this way in a js script? if not, how would i go about doing this another way? can i change a js variable along the way in my PHP code instead, and then reference THAT variable when i get to my js script? i appreciate any help on this...

  • #2
    Regular Coder ajetrumpet's Avatar
    Join Date
    Jul 2009
    Location
    Iowa City, IA
    Posts
    407
    Thanks
    44
    Thanked 5 Times in 5 Posts
    i have solved this issue...thank you to anyone who took the time to read...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •