advancedfuture Posted September 22, 2009 Share Posted September 22, 2009 Trying to echo a HTML tag that has variables in it. Kinda beating my head on the wall with this one unfortunately. How to I echo the anchor text with the ' and " in it. $output = $row['services_address'] . $row['services_address_2'] . $row['services_city'] . $row['services_state']; echo '<a href ="maps.php?address='.$output.'" onClick="window.open('maps.php?address='.$output.'','Page Name','height=500,width=500,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');">View Map</a>'; Link to comment https://forums.phpfreaks.com/topic/175057-solved-having-problems-echoing-html-tag-with-javascript-in-it/ Share on other sites More sharing options...
.josh Posted September 22, 2009 Share Posted September 22, 2009 you need to escape all those single quotes inside your onClick part. better yet, use heredoc so you don't have to worry about escaping quotes: echo <<<EOF <a href ="maps.php?address={$output}" onClick="window.open('maps.php?address={$output}','Page Name','height=500,width=500,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no');">View Map</a> EOF; Link to comment https://forums.phpfreaks.com/topic/175057-solved-having-problems-echoing-html-tag-with-javascript-in-it/#findComment-922665 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.