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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine submit and Thank You

Status
Not open for further replies.

rry2k

Programmer
Jun 28, 2001
678
US
Hi,
I would like to display a simple thank you when a user hits the submit button. I need to send the info with submit and then display a thank you in a pop up. The send works but the thank you doesn't.

Thanks for the help..Russ

<table width=&quot;753&quot;>
<TBODY>
<tr>
<td width=&quot;149&quot;><div align=&quot;center&quot;><center><p class=&quot;MsoNormal&quot;
style=&quot;PADDING-TOP: 50pt;&quot; TEXT-ALIGN:><input name=&quot;REGISTER&quot; type=&quot;submit&quot; value=&quot;SUBMIT&quot;
ACTION=&quot;mailto:rregner@salemsupport.com&quot; METHOD=&quot;post&quot;><input name=&quot;RESET&quot; type=&quot;reset&quot;
value=&quot;Reset&quot;> </p>
onclick=&quot;alert('thank you')&quot;
</center></div><div align=&quot;center&quot; class=&quot;MsoNormal&quot; style=&quot;TEXT-ALIGN: center&quot;></div></td>
</tr>
</TBODY>
</table>
</form>
</div>
</body>
</html>
 
First, you need to put your <input> elements in a <form>

<form name=form1>
<input name=&quot;REGISTER&quot; type=&quot;button&quot; value=&quot;SUBMIT&quot; onclick=&quot;dosubmit(); return true;&quot;>&nbsp; &nbsp;
<input name=&quot;RESET&quot; type=&quot;reset&quot; value=&quot;Reset&quot;>
</form>

function dosubmit()
{
document.form1.action=&quot;mailto:rregner@salemsupport.com&quot;;
document.form1.method=&quot;post&quot;
alert('thank you');
document.form1.submit();
}
 
Thanks alot, I'll give it a shot and I'm sure it will do the trick.
 
I'm new to Javascript and functions in html so please excuse what might be a dumb question. I inserted the code you gave me and it displayed as a literal. Is it incorrect to put this within a table and do I need <script language=&quot;javascript&quot;> before this?

Thanks..Russ
 
Yes, all Javascript functions have to be between <script language=&quot;javascript&quot;> and </script> tags. I usually stick functions in the <head> toward the top of the page, just to keep them in one spot consistently.
 
Makes sense but if I put that at the top which looks like the standard how do I display the submit and reset button at the bottom in the body?
 
function dosubmit() is Javascript, and goes in the Javascript section. The buttons and other inputs are HTML, and you put them where you need them to be on the page. Only the Javascript itself needs to be set apart. The <form> is HTML, not Javascript.
 
With your help I'm getting closer. I have:

<form name=&quot;form1&quot;>
<input name=&quot;REGISTER&quot; type=&quot;button&quot; value=&quot;SUBMIT&quot; onclick=&quot;dosubmit(); return true;&quot;>
<input name=&quot;RESET&quot; type=&quot;reset&quot; value=&quot;Reset&quot;>
</form>
In the body and:

<script language=&quot;javascript&quot;>
function dosubmit()
{
document.action=&quot;mailto:rregner@salemsupport.com&quot;;
document.method=&quot;post&quot;
alert('thank you');

}
</script>

Under the head tag. The alert works but the email doesn't send. When I try to use document.form1.action I get an error that says &quot; Object is null or not an object&quot;

I appreciate your help, Thanks..Russ

 
function dosubmit()
{
location.href=&quot;mailto:rregner@salemsupport.com&quot;;
alert('thank you');
}

will activate the email client with the address inserted and display the thank you message.
 
Ok but what I need to do is send the form results of the application that is filled out.

Thanks
 
You need to refer to the form in your Function by using document then &quot;.&quot; and then the form name (see below). You also don't seem to have any text boxes or anything for the user to put information into to submit so I added one just so you could see it work.

Also, I don't know about this action that you are using, &quot;mailto:emailaddress&quot;. Usually you the action points to a cgi program that will process the informaion, such as: action=&quot;../cgi-bin/my_form_process.cgi&quot;. I think that the mailto will only work if the user has something like Microsoft Outlook set-up on their computer to send the email. I don't use any of those devices so it will not work on mine. Just something to keep in mind. I hope this helped.

<html>
<head>
<title></title>
</head>
<body>
<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;mailto:rregner@salemsupport.com&quot;>
<input type=&quot;text&quot; name=&quot;firstname&quot; value=&quot;&quot;>
<input type=&quot;text&quot; name=&quot;lastname&quot; value=&quot;&quot;>
<input name=&quot;REGISTER&quot; type=&quot;button&quot; value=&quot;SUBMIT&quot; onclick=&quot;dosubmit()&quot;>
<input name=&quot;RESET&quot; type=&quot;reset&quot; value=&quot;Reset&quot;>
</form>


<script language=&quot;javascript&quot;>
function dosubmit()
{

document.form1.submit();
alert('Thank you ' + document.form1.firstname.value + ' ' + document.form1.lastname.value);

}
</script>

</body>
</html>

Later
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top