Click to See Complete Forum and Search --> : prolly something so simple...


Ziggy2003
01-16-2003, 02:51 PM
Hi Folks,

I have what, I hope, is a simple problem. I am using the simple form validation script from here to have a form be completed before sending. My problem is that I want to bring my user to a thank you page when the completed form gets emailed. How and where would I implement this feature. I am doing something wrong because the page just sits there showing the completed form, even tho it DOES send the email.


<script language="javascript">
function checkrequired(which) {
var pass=true;
if (document.images) {
for (i=0;i<which.length;i++) {
var tempobj=which.elements[i];
if (tempobj.name.substring(0,4)=="Cust") {
if (((tempobj.type=="text"||tempobj.type=="textarea")&&
tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&
tempobj.selectedIndex==0)) {
pass=false;
break;
}
}
}
}
if (!pass) {
shortFieldName=tempobj.name.substring(4,30).toUpperCase();
alert("Please make sure the "+shortFieldName+" field was properly completed.");
return false;
}
else {
document.location=("http://216.97.22.73/livemusic-music/thankyou.shtml")
}
return true;
}

</script>



Someone please help me... I am seeing this code in my sleep and that just scares me!! :D

Ziggy

Webskater
01-16-2003, 03:07 PM
I can't make much sense of your code the way it has laid out but I think:
document.location 'near the bottom of your code
should be:
document.location.href
Whether it is in the right place is another thing.
Normally you submit the form to the server, the server processes the form, sends the email and then does whatever you have told it to do - depending on whether you are using a cgi script or asp or whatever.
In the asp world I inhabit you call an email component like ASPEmail from within your page and after the call simply re-direct to a new page. In this way you can be sure the email has been sent before thanking someone for something.
You seem to be trying to submit a form and sending the user to a thankyou page at the same time. I am not sure if this will work but, if it will, the redirect to the thankyou page will need to be after the function has returned true.

Ziggy2003
01-16-2003, 04:02 PM
My bad... I forgot to include the form information...


<Form method="post" action="mailto:webmaster@livemusic-music.com?subject=Support Request" ENCTYPE="text/plain" OnSubmit="return checkrequired(this)">
<input type="text" size="30" name="CustName">
<input type="text" size="30" name="CustAdd">
<input type="submit">&nbsp;&nbsp;<input type="reset">
</Form>


that is not all the form fields but you get the idea. Like I said... the form sends the info the way it is supposed to and gives an alert if a required field is not filled in. However, I want them to be sent to a thank you page once it has been successfully emailed.

Thanks for taking a look!

Ziggy

Ziggy2003
01-17-2003, 12:46 PM
Hi Dave,

Thanks for the info. As you can probably tell, I am a real novice at javascripting. But I am trying to learn! :D

A couple of quick questions:

Looking at the code I showed you, I can see where to change the self.location.href but I do not understand where I should put the rest of the code you suggested (the var url statements).

I am also very curious about the other 3 issues you mentioned regarding the mailto protocol. Can you expand on that?

Thanks again!

Ziggy

Ziggy2003
01-18-2003, 10:45 AM
I must still be doing something wrong. If I include the code where you said, it does go to the thank you page, but doesn't send the email now...

Could I use a THEN statement after the ELSE statement? implement the code you suggested there? so that it has to complete those other tasks before going to the next step?

Thanks again, Dave... I feel I am getting closer!

Ziggy

khalidali63
01-18-2003, 11:23 AM
try the zipped file,It takes care of your concern,
1. email to the provided email address
2. forward the page to another URL

cheers

Khalid

Ziggy2003
01-18-2003, 11:58 AM
Hi Khalid

Thank you for your effort! It worked and worked like a charm! I also thank Dave for his efforts. One day I will know this stuff properly! :D

Thanks again for all your help folks!

May God keep you all safe in the new year!

Ziggy