Solved

How to call php function on html button click.

Posted on 2011-09-06
6
876 Views
Last Modified: 2012-05-12
I want to call php function defined in same file through html button.
Kindly correct the attached code.
 htmlphp.php
0
Comment
Question by:searchsanjaysharma
6 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 100 total points
ID: 36487161
In fact, this solution is doing exactly the same only
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_27292579.html

why ask the same question again?
0
 
LVL 17

Assisted Solution

by:OmniUnlimited
OmniUnlimited earned 100 total points
ID: 36487166
Should be:

<html>
<head>
<script type="text/javascript">
	function f()
	{
		alert('India is great');
	}
</script>
<body>
<form name="f">
<input type="Button" name="b1" value="click me" onClick="f()">
</form>
</body>
</html>

Open in new window

0
 
LVL 15

Assisted Solution

by:Minh Võ Công
Minh Võ Công earned 200 total points
ID: 36487236
html cannot call php function because html in client side and php is server side. it only call a javascript function.
On button click event you can call a javascript function and in js function you can call php script
or you can use AJAX
http://forums.devarticles.com/javascript-development-22/calling-php-functions-with-javascript-3471.html
http://www.daniweb.com/web-development/php/threads/20972
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Assisted Solution

by:Minh Võ Công
Minh Võ Công earned 200 total points
ID: 36487273
0
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 100 total points
ID: 36487671
You can achieve this using Jquery well.

Example
0
 

Author Closing Comment

by:searchsanjaysharma
ID: 36909729
Good
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question