Page 1 of 1

echo link with onclick

Posted: Wed May 04, 2011 11:56 am
by cjkeane
hi everyone.

i have an issue with the onclick portion of a link when echo'd using php. i know its a matter of either a single quote or double quote, but for the life of me, i can't seem to figure it out. any ideas?

i need an onclick event so that a hidden div can be displayed.

Code: Select all

<?php
echo '<td><a href="#?CompanyName='.$result['CompanyName'].'" onclick="showUser(this.value);"> '. $result['CompanyName'] .'</a></td>');
?>

Re: echo link with onclick

Posted: Wed May 04, 2011 1:47 pm
by McInfo
I don't see a value attribute in the <a> tag. Do you mean

Code: Select all

showUser(this.href)

Re: echo link with onclick

Posted: Wed May 04, 2011 1:58 pm
by oscardog
It wasn't anything that you described, you're probably going to kick yourself because there is a random bracket on the end of that line. It should read:

Code: Select all

<?php
echo '<td><a href="#?CompanyName='.$result['CompanyName'].'" onclick="showUser(this.value);"> '. $result['CompanyName'] .'</a></td>';
?>

Re: echo link with onclick

Posted: Wed May 04, 2011 4:09 pm
by cjkeane
thanks! i did find that bracket!