Web Analytics Made Easy -
StatCounter Javascript and PHP - CodingForum


No announcement yet.

Javascript and PHP

  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript and PHP

    Tried asking this before but got no response so I guess I'll try again... Hopefully someone has experienced this before and can shed some enlightenment. Some things work and some don't... I have a time script that just displays the current date and time. It will not work even when adding as echo ("script in here using single ' quotes"); I even tried to end php, stick it in and start php after and it still won't work.
    I also have a more pressing issue regarding popup windows that won't work either.
    CODE: popup.js is enclosed.

    <a href=file.htm' onclick='PopUp(this.href,'550','500');return false'>open this file</a>
    How to call it?

    This is a volunteer site I do for our local little league and really appreciate any help offered.

  • #2
    no code is enclosed. post it as a TEXT file, please.
    on the snippet you did post, i noticed you are missing a single quote before file.htm, not sure that will fix the problem, but it is certainly bad habit.
    "There is more than one way to do it."


    • #3

      I did notice that error too and that is not the problem...
      Here's the code:
      CODE: popup.js
      function PopUp(PopUpUrl,xW,xH){
      var ScreenWidth=window.screen.width;
      var ScreenHeight=window.screen.height;
      var movefromedge=0;
      WinPop=window.open(PopUpUrl,"","width="+xW+",height="+xH+",toolbar=0,location=0,directories=0,status =1,scrollbars=1,menubar=0,resizable=1,left="+placementx+",top="+placementy+",screenX=" +placementx+",screenY="+placementy+",");

      Below is code to access:
      <a href='file.htm' onclick='PopUp(this.href,'550','500');return false'>open this file</a>
      I use it in an array calling from an include
      echo $text['emailpresident']; and have tried as a straight echo ("<above code>");. I have a feeling it's the quote/double quote issue so I tried changing some of those to no avail.
      Maybe there's a function in PHP that opens windows?



      • #4
        Got it!

        Just figured out that using \ in front of the " does the trick.
        Still curious if there is a way to use a PHP function.


        • #5
          no, there isnt. PHP is run at the server, where as Javascript run at the clients computer. That means that javascript cannot do things that PHP can (eg: databases) but it can do other things (eg: dynamic menus)
          PHP Weekly - A PHP Developers Resource
          PHP 5.1.4 and Ruby on Rails web hosting
          Moderator of PHP and Work offers and Requests
          Install Apache/PHP/MySQL
          (by marek_mar) | TinyPlugin Architecture