• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 424
  • Last Modified:

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?

1 Solution
Marco GasiFreelancerCommented:
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... :-)


error77Author Commented:
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.

Lee SavidgeCommented:
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.

error77Author Commented:
I see why leakim971 was using Ajax then....hmm

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now