...

View Full Version : Use javascript to open multiple download boxes



Amethyst
04-12-2005, 09: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

Amethyst

codegoboom
04-13-2005, 12:26 AM
Generically, no.

glenngv
04-13-2005, 09: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.

<html>
<head>
<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);
}
else{
downloadAll(oFrm);
}
}
}
</script>
</head>
<body>
<form>
<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" />
</form>
</body>
</html>

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum