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 3 of 3
  1. #1
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts

    PHP Varibales and JavaScript

    I'm trying to use an already set php vairable in javascript in an if statment. Here is the code.

    if (top.window.document.title !={SITENAME} :: {PAGE_TITLE})
    {
    top.window.document.title={SITENAME} :: {PAGE_TITLE}
    }
    </script>

    But as you can see it wont' work because the if statment thinks that the } in {SITENAME} :: {PAGE_TITLE} is suopposed to end the if statment. Anyone can help?

  • #2
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I usually do

    <? print($VARIABLE_NAME);?>


    and importants thing to remember is that all php code is done 1st
    then send to the client that then does the html/havascript code.

    it is not all done line by line simultanously...

  • #3
    New Coder
    Join Date
    Jan 2004
    Location
    Illinois
    Posts
    72
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well {SITENAME} and {PAGE_TITLE} are set by phpBB. They value they store depends on the value that they are given in the admin CP. Anyone know how to use them exactly as they are in javascript. Or can anyone give me a php script that does the same as this:
    if (top.window.document.title !={SITENAME} :: {PAGE_TITLE})
    {
    top.window.document.title={SITENAME} :: {PAGE_TITLE}
    }
    </script>


  •  

    Posting Permissions

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