Page 2 of 2

Posted: Thu May 10, 2007 3:30 pm
by CoderGoblin

Code: Select all

echo '<script type="text/javascript"><a onclick="ChangeValue();">clickhere</a></script>';
or

Code: Select all

echo "<script type=\"text/javascript\"><a onclick=\"ChangeValue();\">clickhere</a></script>';
Trouble is you were closing the string as part of the string... :wink:

The following link may be useful as it explains several methods to produce strings

Posted: Thu May 10, 2007 5:49 pm
by d3ad1ysp0rk
CoderGoblin wrote:

Code: Select all

echo '<script type="text/javascript"><a onclick="ChangeValue();">clickhere</a></script>';
or

Code: Select all

echo "<script type="text/javascript"><a onclick="ChangeValue();">clickhere</a></script>';
Trouble is you were closing the string as part of the string... :wink:

The following link may be useful as it explains several methods to produce strings
The problem is that those execute javascript functions, he's looking to execute php functions.

Posted: Thu May 10, 2007 8:01 pm
by RobertGonzalez
If you want to be able to execute server side code in client side printed event handlers, use .NET. Aside from that, you will need to write some client side code (Javascript) to handle the events that you are attaching to your client side output (HTML). If you want PHP to handle something when a link is clicked, you will need to translate that click into a server request (either a GET or POST request) which, when it hits the server, PHP can do what you tell it to with that request and provide an appropriate server response.

What you are asking for at the moment is not an option in PHP as PHP processes on the server, not in the browser.

Posted: Sat May 12, 2007 11:51 am
by someguy4
what i was asking was how to execute php codewhen i clicked a link. i never said i t had to be client side.

thanks for the help

Posted: Mon May 14, 2007 10:57 am
by RobertGonzalez
FYI, most of this thread was built around the idea that you were trying to execute PHP code through client interaction. You even posted an example in which you show a click event in an anchor tag. Essentially the context of this thread centered on the ability to call a PHP function by clicking on text in the browser. That is, by its very nature, client side.

I just wanted to clear that up.