blueman378 Posted May 21, 2008 Share Posted May 21, 2008 ho guys, well i have a function that is included in all pages on the site, however i was wondering if i can call it from a form action, so something similar to echo "<form action=\"$catadmin->show_subs($_POST[mainid]);\" method=\"post\">"; obviously that wont work, i know i could do it through having a variable it sends bit i was wondering if it is possible to call it to run directly from the form action? Quote Link to comment Share on other sites More sharing options...
btherl Posted May 21, 2008 Share Posted May 21, 2008 If you want to do something with the user's input after displaying the page but BEFORE form submission, you can use javascript. If you want to do something AFTER form submission then you can do that in the script which receives the form data. If you want to do something BEFORE form display, then you can do that in the script which displays the form. That covers all 3 situations (before form display, after display but before submission, and after submission). Does that make sense? I'm not sure which of those 3 situations you want in your example. Quote Link to comment Share on other sites More sharing options...
blueman378 Posted May 21, 2008 Author Share Posted May 21, 2008 yeah im more curious than anything, like i am doing it after the form has been submitted and a new page loads, i know i can have eg a hidden field in the form and check if that is set if it si then run the function i was jsut wondering if it is possible to run it directly from the action buti giess not| thanks Quote Link to comment Share on other sites More sharing options...
btherl Posted May 21, 2008 Share Posted May 21, 2008 You can't run a php function directly from a form action .. but there are a number of alternatives depending on what you want. 1. Use AJAX to send a request to php, and use javascript to display the response in the browser (or to modify the form before submission) 2. Just submit the form with a hidden variable set and have php pick up on that, and do whatever you want it to do. AJAX is the solution when you want to fetch data from php without reloading and redisplaying the entire page. Quote Link to comment 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.