Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 859

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
<!--- use a count to indicate progress --->
<cfif not isdefined('session.count')>
<cfset session.count = 1>
<cfelse>
<cfset session.count = session.count + 1 >
</cfif>
<!--- the struct to be sent back; using the populate the status and message components of the
progressbar --->
<cfset data = {status=session.count * 0.1,message=(session.count * 10)
<!--- clear count from session to start afresh the next time the program is run --->
<cfif session.count eq 10>
<cfset structdelete(session,"count")>
</cfif>
<!--- data sent back via URL binds must use SerializeJSON() --->
<cfoutput>#SerializeJSON(data)#</cfoutput>
The following CFM code has the JavaScript bind expression:
<head>
<script>
var count = 0;
var init = function()
{
document.getElementById('cfpbLabel').style.display = 'block';
ColdFusion.ProgressBar.show('pBar');
ColdFusion.ProgressBar.start('pBar');
}
var hideProgessBar = function()
{
document.getElementById('cfpbLabel').style.display = 'none';
ColdFusion.ProgressBar.hide('pBar');
}
var getProgessData = function()
{
count++;
if(count > 10)
return {STATUS:1,MESSAGE:"Done"}
else
return {STATUS:count*0.1,MESSAGE:(count * 10) + "%"}
}
</script>
</head>
<cfform>
<div id="cfpbLabel" style="display:none">
Saving File:
</div>
<cfprogressbar
name="pBar"
autodisplay=false
bind="javascript:getProgessData()"
onComplete="hideProgessBar"
width="400"
>
<cfset ajaxOnLoad('init')>
</cfform>
Last updated 1/20/2012
854
& "%"}>

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents