SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    DropDown Menu Script & Downloads

    I have a simple script I'm using on one of my sites that utilizes a drop-down menu to select word (.doc) and acrobat (.pdf) documents to download. However, I would like to modify it so that when the users click on a given link, instead of simply taking them to the page (especially the .pdf formats) and showing the documents in the browser, it will instead allow them to save directly to their harddrive. My forte being more in PHP, I really don't know much about JavaScript. Here's the coding for the script that I am using:
    Code:
    <form name="secretarypacket">
    <select name="secretarypacket" size="1" style="background-color : #336699 ; 
    font-family : arial, verdana, tahoma, sans-serif ; font-size : 12px ; color : #ffffff ; 
    margin : 0px ; padding : 0px ;" onChange="go()">
    <option select="selected">Secretary's Packets:</option>
    <option>:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</option>
    <option value="downloads/secpacket.pdf">Secretary'sretary's Packet (.pdf)</option>
    <option>:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::</option>
    <option value="downloads/secpacketpage1.doc">Secretary's Packet Page 1 (.doc)</option>
    <option value="downloads/secpacketpage2.doc">Secretary's Packet Page 2 (.doc)</option>
    <option value="downloads/secpacketpage3.doc">Secretary's Packet Page 3 (.doc)</option>
    <option value="downloads/secpacketpage4.doc">Secretary's Packet Page 4 (.doc)</option>
    <option value="downloads/secpacketpage5.doc">Secretary's Packet Page 5 (.doc)</option>
    <option value="downloads/secpacketpage6_8.doc">Secretary's Packet Pages 6-8 (.doc)</option>
    <option value="downloads/secpacketpage9.doc">Secretary's Packet Page 9 (.doc)</option>
    <option value="downloads/secpacketpage10.doc">Secretary's Packet Page 10 (.doc)</option>
    <option value="downloads/secpacketpage11_12.doc">Secretary's Packet Pages 11-12 (.doc)</option>
    <option value="downloads/secpacketpage13_14.doc">Secretary's Packet Pages 13-14 (.doc)</option>
    <option value="downloads/secpacketpage15.doc">Secretary's Packet Page 15 (.doc)</option>
    </select> 
    
    <script language="javascript" type="text/javascript">
    <!--
    function go()
    {
    location=document.secretarypacket.secretarypacket.options
    [document.secretarypacket.secretarypacket.selectedIndex].value
    }
    //-->
    </script>
    </form>
    I've also been having some JavaScript errors in IE, but it seems to work in Netscape.... Any ideas?
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    Location
    where the World once stood
    Posts
    700
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi AES,

    Could be a little more explicit regarding the IE errors?

    The code appears to be working -- although I did not test with any actual *.pdf & *.doc files, which brings up...

    If the surfer's browser has the capability of viewing doc &&/|| pdf files, it will. To download the files, you will need to compress them (*.zip) so that browser knows a download is intended.

    Vinny
    Where the World Once Stood
    the blades of grass
    cut me still

  3. #3
    SitePoint Wizard Aes's Avatar
    Join Date
    Jun 2001
    Location
    Oklahoma
    Posts
    3,392
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So there's not a way to have JavaScript tell the browser "Hey; download this to the harddrive?"
    Colin Anderson
    Ambition is a poor excuse for those without
    sense enough to be lazy.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could do it with a little help from one of our buddies(server-side scripting langauge)
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

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