View Full Version : Use javascript to open multiple download boxes

04-12-2005, 10:47 PM
Hi all,

I was wondering if there is any way to use javascript code to open multiple download windows? What I would llike to do is open multiple files users have selected and have the download boxes pop up. Is there a way to use javascript to accomplish this? I do not want to use php to do this because I can't open multiple files because of the HTTP protocol. Any suggestions or samples would be greatly appreciated!! Thanks in advance


04-13-2005, 01:26 AM
Generically, no.

04-13-2005, 10:54 AM
What are the types of files? If the type is zip or any extension that always invokes the download prompt, you can open the download prompts for multiple files simultaneously. You just need to delay the next invocation a bit.

<script type="text/javascript">
var suffix=1;
function downloadAll(oFrm){
var oChk = oFrm.elements["file"+(suffix++)];
if (oChk){
if (oChk.checked){
location.href = oChk.value;
setTimeout(function(){downloadAll(oFrm)}, 1000);
<input type="checkbox" name="file1" id="file1" value="/docs/test.zip" /><label for="file1">test.zip</label><br />
<input type="checkbox" name="file2" id="file2" value="/docs/test2.zip" /><label for="file2">test2.zip</label><br />
<input type="checkbox" name="file3" id="file3" value="/docs/test3.zip" /><label for="file3">test3.zip</label><br />
<input type="button" value="Download All" onclick="suffix=1;downloadAll(this.form);return false" />

04-13-2005, 03:28 PM
Thanks a lot Glen.. I will try that out..