How to make a onclick fumction | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to make a onclick fumction

in php how to make onclick function that's calls a function when click on button

4th May 2018, 4:03 AM
Abhishek Krishna
Abhishek Krishna - avatar
7 Answers
+ 6
php has no way of detecting clicks,its a backend not a front-end language.All of the results are processed before you see it so theres no way of detecting clicks after it has been run.use js
4th May 2018, 4:51 AM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 3
You can detect the click inside a form <form action=”” method=”post”> <input type=”submit” name=”submit”> </form> if(isset($_POST[”submit”])) { /* Clicked */ } submit button returns 1 or True if clicked. False otherwise.
4th May 2018, 8:43 AM
Toni Isotalo
Toni Isotalo - avatar
+ 1
It's not possible to detect click in php, you do add a js script for detection because php isn't a language client! You add the js Script to the end of your code, and you call the action in your HTML script. Look this : https://developer.mozilla.org/fr/docs/Web/API/EventTarget/addEventListener
4th May 2018, 3:16 PM
Damien Tricard
Damien Tricard - avatar
0
awsm its working
4th May 2018, 5:31 AM
Abhishek Krishna
Abhishek Krishna - avatar
- 1
how to use in php
4th May 2018, 4:25 AM
Abhishek Krishna
Abhishek Krishna - avatar
- 1
u re rgtt
4th May 2018, 4:53 AM
Abhishek Krishna
Abhishek Krishna - avatar
- 1
plss tell how to use function in php
4th May 2018, 4:54 AM
Abhishek Krishna
Abhishek Krishna - avatar