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 8865105
In Process

The Archive Base Latest Questions

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

If you select the option with id=second you will be switched back to the

  • 0

If you select the option with id="second" you will be switched back to the option with id="first".

Anyone know how to do this with onclick?

<select id="switchback">
  <option id="first" value="one">Switch back to first option?</option>
  <option id="second" value="two" onclick="...">Yes</option>
</select>

Note: cannot use jQuery.

  • 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-14T16:25:12+00:00Added an answer on June 14, 2026 at 4:25 pm

    If you do want the select to automatically revert to first option, you can do this :

    document.getElementById('switchback').onchange = function(){
        if (this.options[this.selectedIndex].id=="second") {
            this.selectedIndex = 0; 
        }
    };​
    

    Demonstration

    But what is the point in proposing a select, then ? Note that you maybe you’d prefer to disable it :

    <select id="switchback" disabled>
      <option id="first" value="one">You can't change me, lalalala...</option>
      <option id="second" value="two">And you can't see me</option>
    </select>​
    

    Demonstration

    This second solution is clearer for most users.

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

Sidebar

Related Questions

This is my simple markup: <select id=firstSelect> <option value=1>one</option> <option value=2>two</option> <option value=3>three</option> </select>
First option: SELECT Table1.* ,Table2.Price AS Price FROM Table1,Table2 WHERE Table1.ID = Table2.ID Second
I have a situation where the second select list option is generated from the
If user select an option from dropdown it will shown it a textbox but
I have two selects that are linked: Each value of the first select determines
Now I need a three level selected option, and the second selected option will
I have two select elements. Making a choice on the first select will build
I have 2 drop-downs. The first drop-down is the design color. The second one
So I have a select option list with values in it. But as with
I'm trying to style a select option list using CSS. I want more padding

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.