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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:59:07+00:00 2026-06-16T04:59:07+00:00

I am using the code below to hide certain options in my dropdown field.

  • 0

I am using the code below to hide certain options in my dropdown field.

Was banging my head over why, when I click on the first radio button, it works, but won’t work for the others, then realized I need to reset the drop-down to its original options just after clicking another radio button.

My app has a radio-button group, you click on that group of several radios and based on the value of the radio-button, one of the IF statements below runs.

How do I reset a dropdown field to it’s original or complete contents after using the detach function?

I’ve tried these, but they do not work:

$('#3547').find('option:first').attr('selected', 'selected'); 
document.getElementById('3547').selectedIndex = 0; 
document.getElementById('3547').reset();

Code:

var oldoptions = []; 
 if (typeVal == "Art")
         {      
             $('fieldset#section-417').show();
 thisval = 'Art -';
$("#3547").append(oldoptions);  
    oldoptions = $("#3547 option:not(:contains(" + thisval + "))").detach();
}
 if (typeVal == "Chrome")
         {      
             $('fieldset#section-417').show();
 thisval = 'Chrome -';
$("#3547").append(oldoptions);  
    oldoptions = $("#3547 option:not(:contains(" + thisval + "))").detach();
}
 if (typeVal == "Web")
         {      
             $('fieldset#section-417').show();
 thisval = 'Web -';
$("#3547").append(oldoptions);  
    oldoptions = $("#3547 option:not(:contains(" + thisval + "))").detach();
}

re-clarification of functionality needed:

I want to restore all the options that were originally in the dropdown before I filtered some out, so for ex: on load, the dropdown contains 12 options. When the ‘ART’ radio is checked, then only 4 items are displayed in the dropdown. When I click on another radio button “Chrome” for example, I want the original 12 options restored to the dropdown, so the filter code can run again.

  • 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-16T04:59:08+00:00Added an answer on June 16, 2026 at 4:59 am

    Not sure about the surrounding code, but from this snippet you seem to always assign an empty array to oldoptions and then append it to the select (i.e. you’re actually appending nothing).

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

Sidebar

Related Questions

I am using the code below to show/hide a navigation menu on click of
Currently i'm using below code which works well. $(#topperAtBaseLevel:visible, #lowerAtBaseLevel:visible, #midAtBaseLevel).hide(); any optimised code?
I am using the code below to show and hide a div called map
I'm using the code below in the root view controller to hide the UITableView's
I want some hide/show functionality with my div tag. I am using below code
I'm currently using the code below found on web tutorial to show/hide DIVs. It
I added the info button to the navigation bar using below code: UIButton *infoButton
I am using the below code to hide virtual keyboard when i hit Enter
I am using jquery addClass code to show/hide elements when rolling over a div.
I am using the javascript code below to hide/how section based on project type

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.