Log in

View Full Version : Resolved echo php inside javascript



salman1karim
11-04-2013, 12:00 PM
<?php echo "<a href=images/".$rows['filename']. onclick="NewWindow(this.href,'Full Size Preview','400','400','yes','center');return false" onfocus="this.blur()">" . $rows['filename'] . "</a>"; ?>



how to call javascript in php echo statement? As i mentioned in above statement i am getting error.

jscheuer1
11-04-2013, 02:17 PM
You must escape like quotes:


<?php echo "<a href='images/".$rows['filename']."' onclick=\"NewWindow(this.href,'Full Size Preview','400','400','yes','center');return false\" onfocus=\"this.blur()\">" . $rows['filename'] . "</a>"; ?>

Or, and this is probably a better way, echo less of the text:


<a href="images/<?php echo $rows['filename'];?>" onclick="NewWindow(this.href,'Full Size Preview','400','400','yes','center');return false;" onfocus="this.blur();"><?php echo $rows['filename'];?></a>

salman1karim
11-06-2013, 05:17 AM
Thanks Its working perfect.
I am very thankful to you because 90% you helped me when i stuck in the coding. :)