View Full Version : How can I close my window in 3 seconds after submit is clicked?

01-20-2009, 08:15 PM
Hello everyone. My form is going to be a pop up window. How can i close it 3 seconds after the submit button is clicked? Any help is appreciated, thank you.

I need both PHP's message 'Member added successfully' to display and the window to close 3 seconds after.

This is my code (whats in red is my attempt to use setTimeout, but it seems php is overriding it : ( )

$tdtitle = 'New Member';
$conn = db_connect();
if ($action==1){

if ($first){
$sql="INSERT INTO Mail_List(


$msg .= 'Member added successfuly';


$msg .= 'Database ERROR:'.mysql_error();



$msg .= 'You did not fill in all the fields, please try again';



<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title><? echo $tdtitle; ?></title>
<link href="styles.css" rel="stylesheet" type="text/css">
<style type="text/css"></style>
<script type="text/javascript">
function timedMsg()


<form action="<? echo $PHP_SELF; ?>?action=1" method="post" enctype="multipart/form-data" name="form1">
<table border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#CCCCCC" width="665">
<tr bgcolor="#F3F3F3">
<td bgcolor="#F3F3F3" class="td1"><? echo $tdtitle; ?></td>
<td bgcolor="#FFFFFF"><table border="0" align="center" cellpadding="2" cellspacing="0" width="100%">

<td width="12%" class="txt1">First: </td>
<td width="88%"><input name="first" type="text" class="boxes" id="first" value="<? echo $first; ?>" size="70"></td>
<td width="12%" class="txt2">Last: </td>
<td width="88%"><input name="last" type="text" class="boxes" id="last" value="<? echo $last; ?>" size="70"></td>
<td><input name="Submit" type="submit" class="button1" value="Submit!" onClick="timedMsg()"></td>

01-20-2009, 08:54 PM
function infoTimeout() {
if (timeout >0) {
setTimeout(infoTimeout, 1000)

called by

onClick="var timeout = 3; setTimeout( infoTimeout, 1000);"

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum