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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:16:49+00:00 2026-05-15T14:16:49+00:00

Is it possible to make an item disabled/not visable in a select list? What

  • 0

Is it possible to make an item disabled/not visable in a select list?
What I’m trying to accomplish is to, depending on a number of checkboxes, if they are selected, the fields should appear in the dropdown. However, I do have manditory fields that always should be in the dropdown and it should all be in a serten order.

Checkboxes:

<table class="Fields"><tr>
    <td><%=Html.CheckBox("Field1", Model.DisplayField1, new { value = "Field1" })%> Field 1</td>
    <td><%=Html.CheckBox("Field2", Model.DisplayField2, new { value = "Field2" })%> Field 2</td>
    <td><%=Html.CheckBox("Field3", Model.DisplayField3, new { value = "Field3" })%> Field 3</td>
</tr><tr>
    <td><%=Html.CheckBox("Field4", Model.DisplayField4, new { value = "Field4" })%> Field 4</td>
    <td><%=Html.CheckBox("Field5", Model.DisplayField5, new { value = "Field5" })%> Field 5</td>
    <td><%=Html.CheckBox("Field6", Model.DisplayField6, new { value = "Field6" })%> Field 6</td>
</tr></table>

DropDown:

<table cellpadding="0" cellspacing="0">
    <tr>
        <td>Sort 1</td>
        <td><%= Html.DropDownList("drpSortColumn1", (SelectList)ViewData["SortColumns"])%></td>
    </tr>
</table>

The dropdown contains all the checkboxfields + a number of extra fields, that always should be there. There fore I can dynamically remove all and add depending on if it’s checked or not.
I need to do this in the UI as well. Ideally jquery somehow.
So what approch is good for this? Is there a disable option? what would otherwise be an option?

Thanks!

//MrW

Edit:
I tried to do this:

$('#drpSortColumn1 option[value=' + val + ']').hide();

but that doesn’t seem to work out. I don’t know if it simply isn’t possible to hide an option, or if I’m doing it wrong.

  • 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-15T14:16:49+00:00Added an answer on May 15, 2026 at 2:16 pm

    I ended up doing this:

    $(document).ready(function() {
        $('.Fields input[type=checkbox]:checked').click(function() {
    
            $('#drpSortColumn1').children().remove();
    
            jQuery.each(fields, function(val, name) {
                $('#drpSortColumn1').append('<option value="' + val + '">' + name + '</option>')
            });
    
            $('.Fields input:checkbox:not(:checked)').each(function() {
                $('#drpSortColumn1 option[value=' + $(this).val() + ']').remove();
            });
        })
    });
    

    So I store a Json Object with all the orginal fields in it, and at each checkbox click, I remove all items from the dropdown, and regenerate all the items. Then I remove the values from the dropdown depending on what checkboxes was not checked.

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

Sidebar

Related Questions

I'm trying to make a list item expandable. Basically, I want to have a
Possible Duplicate: make drop down list item unselectable I have an asp.net dropdownlist and
Is it possible to make a WPF menu item that, when clicked, does not
Is it possible to make a method return a dynamic List type. Such as
Is it possible to make a multiple choice list with android:choiceMode=multipleChoice or setChoiceMode(ListView.CHOICE_MODE_MULTIPLE) on
Is it possible to make my custom item class so that I can put
Is it possible to make a link that does nothing? I want the item
Is it possible to make an alias for item of an array in scala?
Is it possible to make a double continue and jump to the item after
Is that possible to make a single article as homepage, but not connected 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.