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

  • SEARCH
  • Home
  • 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 516747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:45:48+00:00 2026-05-13T07:45:48+00:00

I have two combo boxes, one for ‘order by’ and the other ‘direction’ (ascending,

  • 0

I have two combo boxes, one for ‘order by’ and the other ‘direction’ (ascending, descending)

I am wondering what is the simplest way to have a default combination… e.g order by A-Z I would want ascending by default and order by views I would want descending by default.

I guess, onChange on the order combobox calling a JS function to set the value of the other combo box… but is there a simpler way?

Here are my comboboxes

<label>Order by:
<select name="o" id="o" onChange="menu.submit();">
    <option value="0" <?php if($_GET['o'] == 0) echo 'selected="selected"'; ?>>A - Z</option>
    <option value="1" <?php if($_GET['o'] == 1) echo 'selected="selected"'; ?>>Number of Views</option>
  </select>
  </label>
 <label>Direction:
  <select name="d" id="d" onChange="menu.submit();">
    <option value="0" <?php if($_GET['d'] == 0) echo 'selected="selected"'; ?>>Ascending</option>
    <option value="1" <?php if($_GET['d'] == 1) echo 'selected="selected"'; ?>>Descending</option>
  </select>
  </label>
  • 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-05-13T07:45:48+00:00Added an answer on May 13, 2026 at 7:45 am

    Why not set the direction based on the order?:

    <label>Order by:
     <select name="o" id="o" onChange="menu.submit();">
      <option value="0" <?php if($_GET['o'] == 0) echo 'selected="selected"'; ?>>A - Z</option>
      <option value="1" <?php if($_GET['o'] == 1) echo 'selected="selected"'; ?>>Number of Views</option>
     </select>
    </label>
    <label>Direction:
     <select name="d" id="d" onChange="menu.submit();">
      <option value="0" <?php if($_GET['o'] == 0) echo 'selected="selected"'; ?>>Ascending</option>
      <option value="1" <?php if($_GET['o'] == 1) echo 'selected="selected"'; ?>>Descending</option>
     </select>
    </label>
    

    Edit: LOL, nm you don’t need the tenary operator to do the same thing. Oops, I think I hit the back button or something.. it made me double post.

    And, yes you could use javascript to set a default option in the direction selector, but maybe it would be better to have a submit button instead? This gives the user more control over the selectors without causing a page reload.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in a form two combo boxes that have the exact itemssource property.
I have a data entry/editing form with two combo boxes (Name and Group). Each
I have five combo boxes. Each one has a different name, but the possible
I have two comboBoxes, one that lists the 7 days of the week and
I have tried to set up combo boxes in the gridview but all the
I have a list that the user can filter in several ways. two of
I need to create several combo boxes to represent enumeration values. I want the
This may seem strange... but I'm wondering if there is anyway to make a
I have an application in Access 2003 that I am working on. In it,

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.