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

Click Submit buttom once to save data AND issue a self-closed message 1

Status
Not open for further replies.

Tivoli0

MIS
Dec 7, 2001
41
IL
Hi all

I have a form that collects input from the user and by clicking the "submit" button the data is saved in a database.

I would like to modify that form to do the following:

Upon pressing the "submit" button, the data will be saved in the database AND a confirmation would be issued to the user that his/her entry was OK. I want that message to popup, remain on screen for 10 seconds, close itself and bring the user back to the main page.

The first problem I'm having is with the setTimeout() function. When I use it, it disappear after the specified time, however it brings the user to the calling frame, NOT the main page.
The second problem is I don't know how to "sequence" the two actions - save data to database and then popup the confirmation window - by clicking the "Submit" button only once. Here is the code:

*************** snip - the form Entry.htm *************
.
.

Code:
<!-- Define the entry form & Check proper fields entry -->

<form onSubmit=&quot;return formValidation(this)&quot; id=&quot;entryForm&quot; name=&quot;entryForm&quot; action=&quot;../ASP/confirmation.asp&quot; method=&quot;post&quot;>
.
.
<font color=&quot;limegreen&quot;><input id=&quot;submit1&quot; name=&quot;submit1&quot; type=&quot;submit&quot; value=&quot;Submit&quot;></font></td>
</form>
******** snip - the popup window Confirmation.asp ********
Code:
<script Language=&quot;Javascript&quot;>
<!--  

	// Define a variable for message window
	var w = open('about:blank', 'thankYouWin',
               'width=300,height=175,resizable=1,scrollbars=1');

	//Define a variable for message text
	var html = '';
  
  
	//Compose the message
		html += '<HTML><BODY>'
			 + '<H2><font color=blue>Thank you for your correct form entries.</font><\/H2>'
			 + 'Your form has been submitted.'
			 + '<\/BODY><\/HTML>';
		w.document.open();
		w.document.write(html);
		parent.window.location=&quot;../html/homepage.htm&quot;;
********************************************************
This will bring the user to the main page but he/she will have to click the &quot;x&quot; on the small window to close it manually!
********************************************************

....and here I'm having the problem...
Code:
	//Can use this function to have message closed and desappear:
	//w.document.close();
	//setTimeout('w.close()', 2000)

//-->

</script>
I appreciate any help!! -Tivoli0
 
Here's some code for a self close script, (without the IE message moaning about the web page is trying to close the window)

Code:
<html>
<head >
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
function closeMe() {
father = window.self;
father.opener = window.self;
father.close(); 
}
// End -->
</script>
</head>
<BODY>
<BODY onLoad=&quot;parent.closeMe()&quot;>
</BODY>
</html>

Obviously as the parent.close is loaded with onload the window closes immediatly, so you just need to call the function when you want the window to close. IE on submit.

Hope you find it usefull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top