echo link with onclick

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cjkeane
Forum Contributor
Posts: 217
Joined: Fri Jun 11, 2010 1:17 pm

echo link with onclick

Post 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>');
?>
User avatar
McInfo
DevNet Resident
Posts: 1532
Joined: Wed Apr 01, 2009 1:31 pm

Re: echo link with onclick

Post by McInfo »

I don't see a value attribute in the <a> tag. Do you mean

Code: Select all

showUser(this.href)
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: echo link with onclick

Post 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>';
?>
cjkeane
Forum Contributor
Posts: 217
Joined: Fri Jun 11, 2010 1:17 pm

Re: echo link with onclick

Post by cjkeane »

thanks! i did find that bracket!
Post Reply