execute a php function when text is clicked [Solved]
Moderator: General Moderators
execute a php function when text is clicked [Solved]
wanted to know to execute a php function you click on some text
Last edited by someguy4 on Thu May 10, 2007 6:13 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
-
thamizhchelvan
- Forum Newbie
- Posts: 23
- Joined: Tue May 08, 2007 2:50 am
Re: execute a php function when text is clicked
someguy4 wrote:wanted to know to execute a php function you click on some text
I think you are going to execute like JavaScript functions?.Note that you cannot do event handling using PHP. You can use AJAX for execute a PHP function in a remote page.
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
How about doing in a simple way by making a query string by calling javascript function. When you click some word, just invoke a js functiion which will reload the page with string attached to the URL.
Suppose, when you click a word x. reload the page like http://xyz.com?word=x. I guess that will make a sense.
Suppose, when you click a word x. reload the page like http://xyz.com?word=x. I guess that will make a sense.
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
How does that make it simple?dibyendrah wrote:How about doing in a simple way by making a query string by calling javascript function. When you click some word, just invoke a js functiion which will reload the page with string attached to the URL.
Suppose, when you click a word x. reload the page like http://xyz.com?word=x. I guess that will make a sense.
Code: Select all
<a href="?word=x">x</a>Anyways, we need more details. People are just guessing at what you want because the request makes no sense.
Re: execute a php function when text is clicked
someguy4 wrote:wanted to know to execute a php function you click on some text
I am also expecting for a good solution
- dibyendrah
- Forum Contributor
- Posts: 491
- Joined: Wed Oct 19, 2005 5:14 am
- Location: Nepal
- Contact:
Oh well, from the query string, you can take the word and do whatever you like. I have written from my knowledge and I know better solutions are yet to come in this thread. I just took a participation hoping it will help someone.d3ad1ysp0rk wrote:How does that make it simple?dibyendrah wrote:How about doing in a simple way by making a query string by calling javascript function. When you click some word, just invoke a js functiion which will reload the page with string attached to the URL.
Suppose, when you click a word x. reload the page like http://xyz.com?word=x. I guess that will make a sense.Code: Select all
<a href="?word=x">x</a>
Anyways, we need more details. People are just guessing at what you want because the request makes no sense.
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Search for Ajax on these forums or as dibyendrah stated have a javascript onclick event send information to reload the page (methods exist for either get or post), during which the PHP code would need to processed.
Note: PHP/Webserver is server side which sends the page to the clients Browser. Once the browser has the page and the user can access it (example click on it) you are restricted to using client side techniques such as javascript unless you pass information back to the webserver/php again (form submit or via javascript ajax are two possible alternatives).
Note: PHP/Webserver is server side which sends the page to the clients Browser. Once the browser has the page and the user can access it (example click on it) you are restricted to using client side techniques such as javascript unless you pass information back to the webserver/php again (form submit or via javascript ajax are two possible alternatives).
trying to do this
but get this error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
did i do it right?
Code: Select all
echo "<script type="text/javascript"><a onclick="ChangeValue()">clickhere</a></script>";but get this error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';'
did i do it right?
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA
-
d3ad1ysp0rk
- Forum Donator
- Posts: 1661
- Joined: Mon Oct 20, 2003 8:31 pm
- Location: Maine, USA