0

I have a variable which stores the path of the file. I am using a pop up window to display that image. I am using following script

function newPopup(url) {
    popupWindow = window.open(
        url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=yes')

Using it as

echo '<td width="150"><a href="JavaScript:newPopup(\'ajax-loader.gif\');">ScreenShot</a></td>';

When I give the name not stored in variable as mentioned above, the script works fine. But when I try to give the variable $end_file, it is not working. I have tried following combinations

 echo '<td width="150"><a href="JavaScript:newPopup(\''.'$end_file'.'\');">ScreenShot</a></td>';
 echo '<td width="150"><a href="JavaScript:newPopup(\'{$end_file}\');">ScreenShot</a></td>';

But none seems to work

Ankuj
  • 703
  • 3
  • 10
  • 27

3 Answers3

0

Remove the quotes around '$end_file' in your first example and it should work.

echo '<td width="150"><a href="JavaScript:newPopup(\''.$end_file.'\');">ScreenShot</a></td>';

For the second example, I believe you have to use double-quotes for string-iterpolation to work.

echo "<td width='150'><a href='JavaScript:newPopup(\"$end_file\");'>ScreenShot</a></td>';
Christofer Eliasson
  • 31,342
  • 6
  • 71
  • 100
0
echo '<td width="150"><a href="JavaScript:newPopup(\"'.$end_file.'\");">ScreenShot</a></td>';
MIIB
  • 1,858
  • 10
  • 19
0

You can simply do the following :

<?php
$x="PHP";
?>    
<script>alert("Hello from <?php echo $x;?>");</script>
Ashraf
  • 2,536
  • 1
  • 18
  • 33