leolim Posted September 7, 2007 Share Posted September 7, 2007 i have created a button in my form (type=button) and on the onClick event, I need to execute some php code or some particular function I don't want to create a submit button instead because cause i want to call different function when different button clicked how should i do that? <head> <title>My Variables HTML Form</title> </head> <body> <h4>My HTML Form</h4> <?php if (isset($_POST['action']) && $_POST['action'] == 'submitted') { echo "SUBMITTED BUTTON"; //calling function display(); } else { echo "ME BUTTON"; profile(); } function display() { echo "you called display function"; } function profile() { echo "you called Profile function"; } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Name: <input type="text" name="personal[name]" /><br /> Email: <input type="text" name="personal[email]" /><br /> <input type="button" name="action" value="submitted" /> <input type="button" name="submit" value="submit me!" /> </form> </body> </html> The program could not work and once runned it display directly "ME BUTTONyou called Profile function" how to correct the program so it runs only when it clicked according to the button triggered? Quote Link to comment https://forums.phpfreaks.com/topic/68294-need-help-in-function-and-button-error/ Share on other sites More sharing options...
teng84 Posted September 7, 2007 Share Posted September 7, 2007 thats ajax thing kindly, explain it clearly!! Quote Link to comment https://forums.phpfreaks.com/topic/68294-need-help-in-function-and-button-error/#findComment-343395 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.