David,


  Remember that CF code is processed on the server and _javascript_ is processed on the client. So, you want to load an _javascript_ array with the data inside the cfloop. After that use a for statement to create document.write statements.


TIA,
Patrick Whittingham
United Space Alliance

-----Original Message-----
From: David Adams [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 02, 2004 2:32 PM
To: CF-Talk
Subject: Forcing control back to the server from the client

The intention of the following code is to force a download to the client of an array of files.  The problem is that it forces out the first file but exits the loop (or leaves it hanging) and control is lost at the server side.  How can the server regain control to carry on with the loop?

<!--- STEP 1: Create Array of files to be used to force the files out to client --->
<cfset arr_filename_to_download = ListtoArray(form.File_to_download,",")>

<!--- STEP 2: Loop through array and have _javascript_ initiate the download to the client --->
<cfloop from="1" to="#ArrayLen(arr_filename_to_download)#" index="i">
<cfset filepath = arr_filename_to_download[i]>
<script language="_javascript_">
alert("File: <cfoutput>#arr_filename_to_download[i]#</cfoutput> will be deleted after it is downloaded.")
helperWindow = "window" + <cfoutput>#i#</cfoutput>
newWindow = window.open('', helperWindow)
newWindow.document.write ("<cfheader name="Content-Disposition" value="attachment; filename=#GetFileFromPath(filepath)#">")
newWindow.document.write ("<cfcontent file="#filepath#" type="application/octet-stream">")
newWindow.document.write ("<script language='_javascript_'>window.close()<\/script>")
</script>
</cfloop>
  _____
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to