Jump to content

echo javascript in php


depojones

Recommended Posts

hello,

 

The following is not working. Can someone help me out.

    echo '<li class="active">
<a href="#" onClick="popupBox('<p>School<br> House <br>Church</p>','<p></p>'); return false">	'.$row['student'].'</li>'; ?>

 

Am trying to echo javascrippt within php query, but it doesn't seem working.

 

note: The javascript is working without the php echo statement

 

Thanks in advance

 

Link to comment
https://forums.phpfreaks.com/topic/203214-echo-javascript-in-php/
Share on other sites

You have unescaped single quotes in your string. Since you've enclosed the string in single quotes, you need to escape any single quotes within the string.

 

<?php
    echo '<li class="active">
<a href="#" onClick="popupBox(\'<p>School<br> House <br>Church</p>\',\'<p></p>\'); return false">	'.$row['student'].'</li>';
?>

 

Ken

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.