Page 1 of 1
issue with echo with a a href and onclick
Posted: Fri May 13, 2011 9:37 am
by cjkeane
i'm having a bit of trouble with this line of code. anyone have any ideas? i know its a matter of quotes in the right place.
Code: Select all
<?php
echo '<td><a href="sr_bytypedetails.php?TypeOfFile='.$result['TypeOfFile'].' onclick="toggle_visibility('details');" > '. $result['TypeOfFile'] .'</a></td>';
?>
Re: issue with echo with a a href and onclick
Posted: Fri May 13, 2011 9:39 am
by John Cartwright
If you want single quotes inside of single quotes, you need to escape them, or use double quotes.
Code: Select all
echo '<td><a href="sr_bytypedetails.php?TypeOfFile='.$result['TypeOfFile'].' onclick="toggle_visibility(\'foo\');" > '. $result['TypeOfFile'] .'</a></td>';
Re: issue with echo with a a href and onclick
Posted: Fri May 13, 2011 9:57 am
by cjkeane
i've reworked it, and i still have an issue.
Code: Select all
<?php
echo '<td><a href="sr_bytype.php?TypeOfFile='.$result['TypeOfFile'] . ' onclick="document.getElementById('\foo\').style.display=(document.getElementById('\foo\').style.display=='\block\')?\'none\':'\block\';"> '. $result['TypeOfFile'] .'</a></td>';
?>
John Cartwright wrote:If you want single quotes inside of single quotes, you need to escape them, or use double quotes.
Code: Select all
echo '<td><a href="sr_bytypedetails.php?TypeOfFile='.$result['TypeOfFile'].' onclick="toggle_visibility(\'foo\');" > '. $result['TypeOfFile'] .'</a></td>';
Re: issue with echo with a a href and onclick
Posted: Fri May 13, 2011 10:10 am
by Celauran
Your last 'block' bit doesn't have the opening single quote escaped; the backslash is after the quote, not before it.
Re: issue with echo with a a href and onclick
Posted: Fri May 13, 2011 10:11 am
by John Cartwright
Look carefully at the position of my escaping backslash, and the position of where you put the escaping backslash.
Re: issue with echo with a a href and onclick
Posted: Fri May 13, 2011 11:47 am
by cjkeane
i see my problem. thanks! issue has been resolved!