1

I am trying to find a way to may a onclick javascript function execute a mailer script that I have setup on the same page. Is this possible?

<input type="radio" name="power" value="Diesel Powered" onclick="executeMailer()">
1
  • PHP runs server side, javascript runs client side. This means there can be no direct calling of php functions from javascript. Are you familiar with AJAX? If not, that may be the route you want to look into. Commented Dec 28, 2011 at 19:45

4 Answers 4

8

You're looking for AJAX.

Sign up to request clarification or add additional context in comments.

Comments

2

This is only possible using Ajax or similar. Google for it, there are enough tutorials and howtos around.

1 Comment

Although I agree it's fairly simple to Google for AJAX, don't be afraid to include a link to a good resource just for good measure!
0

No, your javascript has make a request to the server. The server can then execute the php command.

Comments

0

You need to do a web request from your javascript code.

For instance, if the php code you want to run is located at http://www.yo.com/target.php, you need to make an http request to this page from your javascript code, grab the response and do what you need to do with it.

It is called AJAX.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.