Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Use javascript to open multiple download boxes

    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

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    codegoboom@yahoo.com
    Posts
    999
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Generically, no.
    *this message will self destruct in n-seconds*

  • #3
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,048
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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.
    Code:
    <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>

  • #4
    New to the CF scene
    Join Date
    Apr 2005
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a lot Glen.. I will try that out..


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •