Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display "thanks" page after submit 1

Status
Not open for further replies.

LittleRedHat

Instructor
Apr 20, 2001
202
GB
Using a validateForm function as ACTION and MAILTO my form validates and then emails. Following ok/submit, but not cancel, I need to display the " thank you, your form has been received" page. Other than delivering the form by hand and running back to say "thank you" LOL I've tried every combination and permutation I can think of (plus all those I found from searching the archives) and still can't get the new page to display.

How do I say ... if the form is valid and if the user ok's submit, then please, please display "thanks", else do nothing?

To save my little legs from an overdose of exercise :-s I would be most appreciative of any suggestions.

With thanks ...

LRH
 
how about a javascript that delivers them to a specific page,

like...

**

if(you conditional = 'true') {location.href='thankyou.html';)

else {}

**

i use a basic cgi script that sends the mail and then returns them to a page that says thank you. i list the cgi as the action address.

if you have ?'s...

- spewn



 
sorry...

if (your conditional == 'true')

*spewn
 
Hi Spewn

What service! Thanks a million for the speedy reply.

I follow the logic, but I'm no JavaScript expert and am not sure how/where I would slot what you suggest into my code and how to "call" it. Please could I ask for a little more help.

LRH
 
Sorry! I'm asleep here!

Worked it out ... or so I thought. Validation and submit ok, but still no "thank you".

LRH
 

okay, let's say you are calling you validateForm() function as you explained above...

**
<form action=&quot;validateForm()&quot; method=&quot;POST&quot; name=&quot;form1&quot;>
**

then the javascript...

**
<script language=javascript>

//you run whatever conditionals here, if all goes true, then you get the new page that says thank you gets called...else, they get an error, or however you want to tell them they are not valid.

function validateForm() {

if (conditionals) {location.href = 'newpage.html'}
else {alert('invalid')}

}

</script>
**

this should work. post your code pieces in question if more assistance needed...these forums are very helpful, and the ideas are grand.

let me know. i owe and don't mind repaying.

-spewn
 
Thanks once more. I agree entirely that these forums are a great source of help and support. Like you I try to help in return ... but as you will have guessed, it's not in the JavaScript Forum! LOL

I've printed off your helpful notes and am about to put them to work. In the interim I've been trying to work it out logically. It's correctly checking through and validating all the field in the form, providing error messages, resetting the focus and halting the submit if any field is incorrect. Once all fields are correct the submission goes through. (The cancel submission and reset buttons also work.) The condition I need is - if the form has been submitted then go to the &quot;thanks page&quot; and this what I'm obviously not coding and calling correctly.

I will try to see if I can work out the answer from your advice, if not I'll take you up on your suggestion of posting some of my code.

With thanks again ...

LRH
 
Wish I could give you a million stars! :)

I've spent hours and hours going round in circles on this. So glad you were around to answer my S.O.S. I realised what my mistake was when I read your advice ... I've been trying to write a seperate function instead of including the condition within the validation. (I can't believe how dim I can be sometimes/lots of the time/most of the time!!!)

I've still to check out that it doesn't load the page if the submit is cancelled, but hoepfully now I'm on track I wont need to trouble you again.

With many thanks and all best wishes ...

LRH
 
Sorry Spewn, I'm stuck again, if you still feel like trying to sort me out?

The &quot;thanks&quot; page loads both when the user clicks on ok and on cancel. I'm getting nowhere trying to code &quot;if the user ok's submit, go to the &quot;thanks&quot; page - else if the user cancels, do nothing.

As in my excitement last night I effectively closed this thread, I'll repost in case you don't pick this up.

With many thanks again for all your help last night.

LRH


 
post the code here, with aids along the way explaining what you are trying to do...good?

spewn
 
Hi again Spewn,

Thanks once more.

Have tried to cut long coding short … Hope I haven’t left out anything essential in the abbreviated examples below!

The FORM1.html (below) page runs fine. It validates, submits/mails, cancels and resets.

<HTML>
<HEAD>
<TITLE>Order Form</TITLE>

<SCRIPT language=JavaScript>
<!--
function validateForm()
{
if (document.order.name.value == &quot;&quot;)
{
alert (&quot;Please Enter Your Name&quot;);
document.order.name.focus()
return false;
}
// end name if
// end validateForm()
}
//-->
</SCRIPT>
</HEAD>

<BODY bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot; link=&quot;#3300ff&quot; vlink=&quot;#990099&quot; alink=&quot;#ff0000&quot;>
<form method=post name=order onsubmit=&quot;return validateForm();&quot; action=&quot;mailto:xxxxx@etc?subject=order&quot; enctype=&quot;text/plain&quot;>

<table width=&quot;85%&quot; align=&quot;center&quot;border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;15%&quot;>
<p><b><font face=&quot;Times New Roman&quot; size=&quot;3&quot;>Full Name</font></b></p></td>
<td>
<p><input type=&quot;text&quot; name=&quot;name&quot; size=&quot;25&quot; maxlength=&quot;25&quot;></p>
</td>
</tr>
</table>
<table width=&quot;85%&quot;>
<tr>
<td>
<p align=&quot;center&quot;><input type=&quot;submit&quot; name=&quot;submit&quot;value=&quot;Submit&quot;>
     
<input type=&quot;reset&quot; name=&quot;reset&quot; value=&quot;Reset&quot;></p>
</td>
</tr>
</table>
</form>
</body>
</HTML>
-------------------------------------------
THANKS.html

<HTML>
<HEAD>
<TITLE>Thanks</TITLE>
</HEAD>
<BODY bgcolor=&quot;#ffffff&quot; text=&quot;#000000&quot; link=&quot;#3300ff&quot; vlink=&quot;#990099&quot; alink=&quot;#ff0000&quot;>

<table width=&quot;85%&quot; align=&quot;center&quot;border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td width=&quot;15%&quot;>
<p align=&quot;center&quot;><b><font face=&quot;Times New Roman&quot; size=&quot;3&quot;>Thank You!</font></b></p></td>
<td>
</tr>
</table>
</body>
</HTML>
-----------------------------------------------------
What I’m wanting to happen : When the user clicks the submit button ...

1. the form is validated using the validateForm function, before displaying the submit or cancel option.

2.if the user clicks OK to submit the form, the form is submitted/mailed and the confirmatory page (thanks.html) is displayed, replacing the form.

3. but if the user cancels the submission, then the submission/mailing is cancelled and the completed form stays displayed.
--------------------

My attempts at a submitForm function have resulted in - if a field was missed/wrong the error message would display, but then immediately change to the submit/mail &quot;popup&quot; without chance of making an entry in the field box. I abandonded this idea.
------------------------------------------------

These are the two “almost there” versions I have tagged on to the end of the validateForm function for the pages I’m actually using. I've tried to explain what happens with each ... hope I've explained clearly.

VERSION 1

if(!confirm(&quot;Press OK To Proceed, Or Press Cancel To abort the submission&quot;)) history.go(0);
else
{
location.href=thanks.html';
}

All works to plan if the user ok's. They then get the &quot;you are about to email&quot; popup and on ok-ing that the form submits/mails and the required thanks.html page replaces the form.
BUT if the user cancels, the &quot;you are about to email&quot; popup still displays and they have to cancel again. I wanted to avoid this and managed it in …

VERSION 2 ...

if (confirm(&quot;You are about to e-mail your order. Click OK to continue. Click Cancel to abort.&quot;))
{
location.href=thanks.html';
}
else
{
alert(&quot;\n Your order has been cancelled.&quot;);
return false;
}

… and the cancel cancels fine on the first message.
OK works fine... puts up the &quot;you are about to email&quot; popup and ok-ing that submits/mails the form and the finish.html page replaces the form.
BUT if the user cancels the submission at this (&quot;you are about to email&quot; popup) stage the thanks.html page is still displayed instead of the form remaining on screen.

Thanks as always ...

LRH
 
Hi Spewn,

Hasty posting, hopefully in time to save you time.

I'm up and running! LOL

In case you're curious and in case it might help someone else sometime, the solution is ...

if (confirm(&quot;You are about to e-mail your order. Click OK to continue. Click Cancel to abort.&quot;))
{
location.href='accept.html';
}

else
{
alert(&quot;\n Your order has been cancelled.&quot;);
return false;
document.order.name.focus();
document.order.name.select();
}

The key is ...

document.order.name.focus();
document.order.name.select();


Out of all the hundreds of thoughts Ive had, the one I almost never thought of!

I can't think of another way to say it, so please will you settle for an action replay ...

THANK YOU!

LRH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top