Page 1 of 1

Embedding Javascript into PHP/HTML

Posted: Mon Feb 28, 2005 10:10 am
by TheOracle
Hi All,

I am trying to write a basic function which just uses a while loop to display a table with data returned from a select statement.

One of the columns contains a string which I want as a hyperlink. This is not a problem in itself, but I want the hyperlink to produce a pop-up.

Unfortunately it doesn't seem possible to incorporate the:

onclick="function('url?id='.$variable['name'].' ');"

into the hyperlink because there are too many apostrophes/speech marks. I also can't create this as a variable external to the function as it won't pick up the correct variable in the hyperlink.

Does anyone have a working example that I can look at, or does anyone have any advice they can give me?

Many thanks,

Posted: Mon Feb 28, 2005 10:17 am
by patrikG

Posted: Mon Feb 28, 2005 10:27 am
by TheOracle
Thanks, but I'm not entirely sure what to do with that? Can you give me an example based on javascript?

Posted: Mon Feb 28, 2005 10:37 am
by CoderGoblin
I think what you are after can be achieved with the escape character.

Code: Select all

$url=urlencode("mylink?id=$variableї'name'];
echo("<a href="#" onclick="function('$url');"");
I would advise you to look up urlencode to know what is is doing and understand why you should use it.

Posted: Mon Feb 28, 2005 11:28 am
by guest
<A HREF="whatever.php?a=b&c=d" target="_blank">Message</A>



Scottie_Too_Hottie7