<!--- 
 Filename: FlushMeter.cfm
 Created by: Nate Weiss (NMW)
 Purpose: Diplays a progress meter as a lengthy task is completed
--->


<html>
<head><title>&lt;cfflush&gt; Example</title></head>
<body>
 
 <!--- Initial Message --->
 <p><strong>Please Wait</strong><br>
 We are processing your order.<br>
 
 <!--- Create the "Meter" image object --->
 <!--- Initially, it displays a blank GIF --->
 <img name="Meter" src="../images/PercentBlank.gif" 
 width="200" height="16" alt="" border="0">
 
 <!--- Flush the page buffer ---> 
 <cfflush>

 <!--- Loop from 0 to 25 to 50 to 75 to 100 --->
 <cfloop from="0" to="100" step="25" index="i">
 <!--- Time-consuming process goes here ---> 
 <!--- Here, ColdFusion waits for 5 seconds as an example --->
 <!--- Do not use this technique in actual code! --->
 <cfset initialTime = now()>
 <cfloop condition="dateDiff('s', initialTime, now()) lt 2"></cfloop>
 
 <!--- Change the SRC attribute of the Meter image --->
 <cfoutput>
 <script language="JavaScript">
 document.images["Meter"].src = '../images/Percent#i#.gif';
 </script>
 </cfoutput>
 <cfflush>
 </cfloop>

 <!--- Display "Success" message --->
 <p><strong>Thank You.</strong><br>
 Your order has been processed.<br>
</body>
</html>
