Link to home
Start Free TrialLog in
Avatar of error77
error77

asked on

onclick execute php function

hi all,

I know how to run some javascript when I click on a link using onclick="runthis();" ... my question is ... how can I do this and run a php function instead?

thanks
ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I'm sorry, but you can't. Php is a server-side language not a client side one as Javascript is, so you can't simply run a php function clicking a button.
 Maybe you can tell what does that function and I could find a solution to use it - maybe... :-)

Cheers

Avatar of error77
error77

ASKER

I didn't want to use ajax. I just wanted to run some php code when I click the onclick event link but don't need a return ... I would just add an alert saying "Done!" or something link that.

I actually need something simpler than that.

Thanks
You can't directly. You need to post back to the server and call the function serverside. PHP is a server side language and javascript is typically a client side language. The client side script interacts with the page and the clientside DOM only. It doesn't interact with anything server side.

Avatar of error77

ASKER

I see why leakim971 was using Ajax then....hmm