Jump to content

[SOLVED] Having problems echoing HTML tag with javascript in it


advancedfuture

Recommended Posts

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>';

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;

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.