-3

I have a problem with calling a phpfunction from a onclick() event.

<button onclick=delete($a) >click here</button>


<?php 
Function delete($a)
{
----statements----
}

?>

Please help me solving this functiom call

Barmar
  • 741,623
  • 53
  • 500
  • 612
Arun
  • 25
  • 5
  • 2
    Learn how PHP and Javascript works... PHP is server side and javascript is client side. Only way to make something like this work is with JS/PHP is through AJAX. – Epodax Sep 22 '15 at 19:42

1 Answers1

1

You cannot call a php function from a javascript onclick event that way. php is strictly server side, the only way is to make an ajax call to a script that will run the function and return the result. Once the page is served, all trace of php disappears, there is no reference or anything of php left in the client side.

taxicala
  • 21,408
  • 7
  • 37
  • 66