Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8803743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:25:16+00:00 2026-06-14T01:25:16+00:00

I have two select boxes like so: <select id=one> <option value=default>Select File</option> <option value=path/to/file1>File

  • 0

I have two select boxes like so:

<select id="one">
    <option value="default">Select File</option>
    <option value="path/to/file1">File One</option>
    <option value="path/to/file2">File Two</option>
    <option value="path/to/file3">File Three</option>
</select>

<select id="two">
    <option value="default">Select File</option>
    <option value="path/to/file4">File Four</option>
    <option value="path/to/file5">File Five</option>
    <option value="path/to/file6">File Six</option>
</select>

<p class="button_image">
    <a onclick="download(document.getElementById("one").value)"></a>
</p>

Here is my download function:

function download(file) {
    if (file == 'default') return;
    window.location = 'http://www.mysite.com/download/' + file;
}

This works fine for one select box, but I can’t seem to figure out how to use the same button image. Oh yah, the p.class=button_image has background image that is a button with hover effects.

The reason I want these select boxes to be separate is because they each represent a group of files, eg, 32-bit versus 64-bit. So they cannot be combined, because it won’t flow with the page design.

I’ve tried some if/else blocks in PHP using the getElementById but I’m getting stuck. This is what I tried and it seems to only partially work:

<?php

if ('document.getElementById(\"one\")' == 'one') {
    echo "<a onclick='download(document.getElementById(\"one\").value)'></a>";
}

else if ('document.getElementById(\"two\")' == 'two') {
    echo "<a onclick='download(document.getElementById(\"one\").value)'></a>";
}

?>

I should note that I don’t necessarily need to use PHP in this case to solve this problem. It was just an option I tried because I’m using PHP for the server-side programming. I could be happy with any number of options, so long as they work.

Thanks.

** EDIT **

This design might be flawed. But the intention is that either a file from box one is downloaded OR a file from box two is downloaded. If one selection is made, then the other should be rest to default and vice versa. This is what I’m working on now.

** EDIT **

I ended up goign with Dawson Loudon’s answer for one part and I created another function based on Barmar’s comment that looks like this:

// resets other select box when selected
function reset_index(id) {
    document.getElementById(id).selectedIndex = 'default';
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:25:17+00:00Added an answer on June 14, 2026 at 1:25 am

    Try replacing this:

    <p class="button_image">
        <a onclick="download(document.getElementById('one').value)"></a>
    </p>
    

    with:

    <p class="button_image">
        <a onclick="download(document.getElementById('one').value, document.getElementById('two').value)"></a>
    </p>
    

    and then replace your download function with this:

    function download(file1,file2) {
        if (file1 == 'default' && file2 == 'default'){
          return;
        }
        else if(file1 != 'default'){
          window.location = 'http://www.mysite.com/download/' + file1;
        }
        else{
          window.location = 'http://www.mysite.com/download/' + file2;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have two multiple select boxes like this <select id=foo multiple=multiple> <option value=1>Option
I have a table with three columns, and two cells contain select boxes with
I have a form with two text boxes, one select drop down and one
I have two option boxes populated. I would like to display a vertical straight
I have two input boxes and two select boxes and would like to display
I have two select boxes (one for Car Types and the other for Car
I have two multi-select list boxes; one with months and one with years such
I have two select boxes with dates. See here the jsfiddle: http://jsfiddle.net/egrba/ The people
I have two identical select boxes (aside from their names, of course), and I
I currently have a ajax script that dynamically builds two select boxes enabled with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.