November 5, 20169 yr How do I add php to button onclick? I dont wish to use jquery as i have been using javascript and i dont wanna complicate things and jqeury is all i could generally find. does it basically work the same way as in javascript, you make a function using php then call the function using inclick ? e.g. <?php function Myfunction(){}?><input type = "button" name="click here" onClick="return Myfunction()";>sorry for my n00b question haha
November 5, 20169 yr PHP is Server Side, the onclick event is typically used with Javascript, which is client side, PHP is processed on the server and compiled/converted to HTML which you see in the browser window, your PHP functions and variables are never seen client side. If you want the form to get processed in PHP without using Javascript you'll have to use a form and send the post data to your PHP script for processing. <form method="post" action="myPHPScript.php"> ... <input type="submit" value="Click Here"/> </form>
Create an account or sign in to comment