Single select dropdown menu with two result buttons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jumprope
    New Member
    • Dec 2012
    • 3

    Single select dropdown menu with two result buttons

    I've got a choose file type select menu of two options: PDF and PowerPoint. Once you select PDF you can either click Download or Preview button.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    not every browser supports PDF viewing out of the box.

    besides that, whether a file is displayed or downloaded is usually out of the scope of JS.

    Comment

    • jumprope
      New Member
      • Dec 2012
      • 3

      #3
      Can someone help me out with the code? Trying to achieve something like this.

      (html)
      Code:
      <form action="../">
      <select name="fileType">
          <option value1="name.pdf" value2="pdf.zip">PDF</option>
          <option value1="name.ppt" value2="ppt.zip>PowerPoint</option>
          <option value1="name.xls" value2="excel.zip>Excel</option>
      </select>
      
      <input type="button"
          value="Open in New Window!"
          onclick="ob=this.form.myDestination;window.open(ob.options[ob.selectedIndex].value1)">
      
      <input type="button2"
          value="Open in New Window!"
          onclick="ob=this.form.myDestination;window.open(ob.options[ob.selectedIndex].value2)">
      </form>
      
      <SCRIPT LANGUAGE="javascript">
      <!--
      function OnChange(dropdown)
      {
          var myindex  = dropdown.selectedIndex
          var SelValue = dropdown.options[myindex].value
          var baseURL  = <Some value based on SelValue>
          top.location.href = baseURL;
          
          return true;
      }
      //-->
      </SCRIPT>
      Last edited by Rabbit; Dec 10 '12, 09:53 PM. Reason: Please use code tags when posting code.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        So, Jumprope: is that YOUR code that you posted or an example of what you want to have happen when everything is done and said?

        IF that is YOUR code, then can you take a few moments and tell us what is wrong with it? What is it doing that it shouldn't and what have you tried to do to fix it?

        Comment

        • jumprope
          New Member
          • Dec 2012
          • 3

          #5
          This is a two part question.
          1) Code above is just an example.
          2) I want a PDF file once selected to both dowload or just preview (without having to zip up every PDF file.

          Comment

          Working...