Jump to content

echo php vars in javascript new window function


xjasonx

Recommended Posts

echo 'window.open("nwindow.php?id=$id&title=$title","newwindow",config="height=500,width=400")';

When the new window opens, it just says "$title". I've been messing with the quotes forever and now I'm really sleepy. I'm sure this is an easy fix for someone.

You cannot interpolate variables inside single quotes.  Try something like this:

 

echo "window.open(\"nwindow.php?id=$id&title=$title\",\"newwindow\",config=\"height=500,width=400\")";

 

Use double quotes when you contain variables inside an echo statement, or concatenate, or as I did above, escape other double quotes.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.