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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:26:26+00:00 2026-05-27T11:26:26+00:00

Usage: I have a form that has a select drop-down that’s controlled by another

  • 0

Usage:

I have a form that has a select drop-down that’s controlled by another select drop-down. On loading the page (if values where selected before, PHP loads them) select drop-down #2 hides several options (this works). When selecting a particular option with select drop-down #1, select drop-down #2 hidden options become available (.show(), this works).

The problem: (An example to outline the problem: http://jsfiddle.net/RqhbY/7/)

When the hidden options are shown/available and one is selected and then the select drop-down #1 changes that value that hides the options in drop-down #2, On submission the selected hidden value gets submitted.

How can I un-select/reset the selected option that is now hidden?

  • 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-27T11:26:27+00:00Added an answer on May 27, 2026 at 11:26 am

    http://jsfiddle.net/RqhbY/8/

    Try changing:

    $('select[name=two[0]] option').attr('selected', false);
    

    with:

    $('select[name=two[0]] option').removeAttr('selected');
    

    UPDATE

    OK, I tested the above code in IE 8 and the disabled <option> is still selected. This seemed to work however:

    $('select[name=two[0]]').children('option').removeAttr('selected').filter(':nth-child(1)').attr('selected', true);
    

    Demo: http://jsfiddle.net/RqhbY/9/

    Note that you may want to update the .filter() call to only select non-disabled options but I’ll leave that for you.

    UPDATE

    If you call .attr('selectedIndex', -1) on the <select> element then you can have no <option>s selected. The drop-down will not show a value but instead will be blank.

    Demo: http://jsfiddle.net/RqhbY/10/

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

Sidebar

Related Questions

I have a form that is loading quite an amount of data from SQL
I have data of program usage in excel file, the data has date and
I have heard from many people that usage of templates make the code slow.
I have a Samurize config that shows a CPU usage graph similar to Task
I have a UserForm class which has a select list populated from a related
With user controls on a page, I understand that every control has an impact
I have jsf page: .... <form jsfc=h:form action=> <h:dataTable value=#{newMusician.strings} var=preferredMusicGenre id=musicGenresSelectTable> <h:column> <h:inputText
I post some data over to another page from a form. It's a shopping
I have a winForm panel that has a flash ative x control embedded in
using c# vs2008 winforms. My standard forms have a typical usage pattern of Form

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.