Hi,
I have got a form within abc.php page with method=post, onsubmit="return validateForm(this)" and action="xyz.php"
once user clicks submit - JavaScript function validateForm validates the form onsubmit and if it's all correct the page goes to xyz.php to run the script thr to send email.
But instead of going to the xyz.php page can i have this implemented in the same page ?
I tried placing the xyz.php script in abc.php but it doesn't seem to like it.
Any ideas
Thank you.
onsubmit and action
Moderator: General Moderators
-
amargharat
- Forum Commoner
- Posts: 82
- Joined: Wed Sep 16, 2009 2:43 am
- Location: Mumbai, India
- Contact:
Re: onsubmit and action
Sure, You can submit to similar page where you are currently, just you have to check posted values are empty are not and then only allow script to proceed for further execution.
Re: onsubmit and action
ok so you mean something like below -
if this is correct then it's not working - onsubmit the form goes to javascript function to validate and if validation passes it looks to action and if i set action to same page then nothing happens. (
Code: Select all
if(isset($_POST['submitted']))
{
// send email code goes here...
}
-
amargharat
- Forum Commoner
- Posts: 82
- Joined: Wed Sep 16, 2009 2:43 am
- Location: Mumbai, India
- Contact:
Re: onsubmit and action
Any error javascript error it is giving ?
or
Just paste your javascript code here so that i can review it
or
Just paste your javascript code here so that i can review it
Re: onsubmit and action
it seems to be working now - strange
now i have another problem - In form we need to type action="abc.php"
but now i have a situation where i don't know the name of the file because it is set up in ids using short url. So is there any way i can force the action to run in the same page without writing the abc.php bit.
Thanks
now i have another problem - In form we need to type action="abc.php"
but now i have a situation where i don't know the name of the file because it is set up in ids using short url. So is there any way i can force the action to run in the same page without writing the abc.php bit.
Thanks