Display a message for "x" seconds only

I have a form where after it is submitted it says:

“Update Successful”.

How can I echo that message for only 5 seconds?

The reason I want it to update for 5 seconds only is because if you want to submit the form a second time “Update Successful” is already at the top, and it because beside the point of having it there.

This is my attempt at getting it work work. I have tried various combinations and ways… but none work yet.


<div class="breadcrumb"><a href="/admin/edit-page.php">Edit Page</a> &raquo; NotePad</div> <?php 
if (isset ($_GET['status'])) {
  if ($_GET['status'] == "done") {
      if (!isset($_GET['status'])) {
      set_time_limit(10);
            echo '<div class="success_message"><p>Update Successful</p></div>';
    } 
    
  }
}
?>

You can use setTimeout() to hide the div after 5 seconds.

That would be something you would need to achieve using JavaScript or via redirect after 5 seconds to the same page but without the message passing a flag of some kind.

Well I can’t redirect after 5 seconds, because the person might be editing. They will start typing again and the page will take off. So that’s out.

I will look at setTimeout()

Thanks Kalon…

I managed to write this from that page:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<script type="text/javascript">
//<![CDATA[
function timedMsg()
{
var t=setTimeout("alert('1 seconds!')",5000);
}
//]]>
</script>

  <title></title>
</head>

<body>
  <script language="JavaScript" type="text/javascript">
//<![CDATA[
<!--
timedMsg()
//-->
//]]>
</script>
</body>
</html>

Is it possible to reverse the script? I don’t want an alert after 1 second. I want text to go away after 1 second.

This will cause the heading to disappear after 4 seconds.

 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
 
function timedMsg()
{
var t=setTimeout("document.getElementById('myMsg').style.display='none';",4000);
}
 
</script>
  <title></title>
</head>
<body>

<h1 id="myMsg">This will disappear after 4 seconds</h1>
  
<script language="JavaScript" type="text/javascript">timedMsg()</script>

</body>
</html>