#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    4
    Rep Power
    0

    Passing PHP Vars Into A Javascript


    I'm having a slight difficulty with this.... I have a small piece of javascript that opens a new window, however when I try to pass a single variable into the mix nothing works anymore - no new windows appear, nothing!

    I'm getting grumpy about it, probably unneccessarily.

    My code is pretty simple -

    <script type="text/javascript">
    <!--
    window.open ("<? echo 'includes/invoices/print.php?inv_no=$inv_no' ?>,"new_window","width=800,height=500,location=0,menubar=,resizable=0,scrollbars=yes,status=0,titleb ar=1,toolbar=0");
    -->
    </script>

    What am I doing wrong here?
    Last edited by Bio; May 2nd, 2003 at 11:00 PM.
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    4
    Rep Power
    0
    I figured out a solution... not sure why it works, but it does.

    $page = "includes/invoices/print.php?inv_no=$inv_no";
    ?><script type="text/javascript">
    <!--
    window.open ("<? echo $page ?>","new_window","width=800,height=500,location=0,menubar=,resizable=0,scrollbars=yes,status=0,title bar=1,toolbar=0");
    -->
    </script><?
  4. #3
  5. geek of all work
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Location
    Vermont, USA
    Posts
    13
    Rep Power
    0
    You first echo has the page url string in single quotes, and so the $inv_no wasn't being interpreted.

IMN logo majestic logo threadwatch logo seochat tools logo