Quick question: PHP/Javascript syntax problem

gottaloveit

New Member
Messages
33
Reaction score
0
Points
0
The page I'm working on returns a table of results from a mySql database. One of the results, the name id, is a hyperlink. When clicked, I want that hyperlink to load an iframe on the same page.

I can load the iframe using a line of java. However, when I insert that line of java into the hyperlink that is returned from the mysql search, something doesn't work right, the iframe doesn't load.

The line of javascript that works to load the iframe is:

<a href="javascript:loadintoIframe('myframe', 'iframe.php')">Link</a>


What I am trying to do is this:

echo ("<td> <a href='javascript:loadintoIframe('myframe', 'iframe.php')'>" . $row['name'] . "</a> </td>");

I've tried tweaking this line but it often causes a PHP error that prevents the page from loading.

THanks for any help!
 

woiwky

New Member
Messages
390
Reaction score
0
Points
0
First of all, Javascript isn't Java.

Second, I think your problem may be that you're putting single quotes within single quotes. Try changing the echo statement to:

Code:
echo "<td> <a href=\"javascript:loadintoIframe('myframe', 'iframe.php')\">" . $row['name'] . "</a> </td>";
I took the parentheses out just because they aren't needed for echo statements. In fact, it's slightly less efficient to use them there.
 

gottaloveit

New Member
Messages
33
Reaction score
0
Points
0
Beautiful! It works like a charm. Thanks very much! I'll remove the parentheses from my PHP. I think I need to get a book on PHP and learn more about syntax.

Also thanks for informing me about java vs javascript - i just looked up the difference and now I understand what they are (I used to assume they were the same thing).
 
Top