?
Solved

Can we call a php function on html buttons onClick event?

Posted on 2003-03-07
8
Medium Priority
?
18,358 Views
Last Modified: 2013-12-13
I am Suffering fom a problem.
i want to execute particular php code when a button is clicked . So i write a function and called on the onclick event of a Button. But it wont Work.As in Java Script we can call javascript Function on the onclick event.Thats why i try it.
Please Help me if any can........      

                                                Nilesh_K
0
Comment
Question by:Nilesh_K
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 6

Expert Comment

by:carchitect
ID: 8087902
what are you trying to do nitish i hope i can help you, pls post your complete query, this is kapil.
regards
0
 
LVL 1

Expert Comment

by:pcaylor
ID: 8088217
The short answer is that you cannot directly call a PHP script from an HTML page as you can a JavaScript.  The reason is that PHP is a server side script language, while JavaScript is client side.

With that said, there are a couple of possible work arounds depending on what you are trying to do.  Could you give me a little more information about what you are trying to accomplish?

-Peter
0
 
LVL 1

Accepted Solution

by:
Jonza earned 200 total points
ID: 8108977
you cant access the php code directly from form but it sure works if you make the onclick event to submit your form.


----- test.php -----
<?php
 function myFunction(){
   print("Yeah, this is my function!!<br>");
 }//myFunction()

if(isset($execute) && $execute == 1){
  myFunction();
}
?>

<input type='button' onclick="window.location='test.php?execute=1';" value='Event'>
-------------------

that should trigger the myFunction() =)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Nilesh_K
ID: 8110401
Thanks Joza it is a great Idea.
You Help me allot thanks once again
 
0
 
LVL 1

Expert Comment

by:Jonza
ID: 8110419
no problem =)
0
 
LVL 12

Expert Comment

by:lexxwern
ID: 8112923
Nilesh please accept Jonza's comment and the answer.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

741 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