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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:18:55+00:00 2026-06-07T17:18:55+00:00

Ok, I am working on an ASP.NET-MVC web app that has a page with

  • 0

Ok, I am working on an ASP.NET-MVC web app that has a page with several rows and columns of drop down lists. My intention is to enable/disable the DDLs in columns 2 and three, based on the selection of the DDL in column1.

So far, I am only able to enable/disable ALL of the DDLs on the entire page at the same time. I need to figure out how to make the event fire only as it relates to the DDLs on a specific row.

Here’s my code so far:

HTML —

<select class="med" id="SubTrades_1__Condition" name="SubTrades[1].Condition"><option     value="">- Select -</option>
<option value="N/A">N/A</option>
<option value="Missing">Missing</option>
<option value="New">New</option>
<option value="Excellent">Excellent</option>
<option value="Good">Good</option>
<option value="Fair">Fair</option>
<option value="Poor">Poor</option>
<option value="Very Poor">Very Poor</option>
</select>

<select class="med" id="SubTrades_1__Quality" name="SubTrades[1].Quality" disabled="disabled"><option value="">- Select -</option>
<option value="Designer">Designer</option>
<option value="Custom">Custom</option>
<option value="Semi-Custom">Semi-Custom</option>
<option value="Builder">Builder</option>
<option value="Basic">Basic</option>
<option value="Economy">Economy</option>
</select>

<select class="med" id="SubTrades_1__Age" name="SubTrades[1].Age" disabled="disabled">        <option value="">- Select -</option>
<option value="Original to home">Original to home</option>
<option value="Brand New/Recent Upgrade">Brand New/Recent Upgrade</option>
<option value="1 to 3 Years">1 to 3 Years</option>
<option value="4 to 6 Years">4 to 6 Years</option>
<option value="7 to 10 Years">7 to 10 Years</option>
<option value="11 to 15 Years">11 to 15 Years</option>
<option value="16 to 20 Years">16 to 20 Years</option>
<option value="21 to 30 Years">21 to 30 Years</option>
<option value="31 to 40 Years">31 to 40 Years</option>
<option value="41 to 50 Years">41 to 50 Years</option>
<option value="Over 50 Years">Over 50 Years</option>
</select>    

My Script:

$("[name][name$='Quality']").prop("disabled", true);

$("[name][name$='Age']").prop("disabled", true);

$("[name][name$='Condition']").change(function () {

if ($(this).val() == "" || $(this).val() == "N/A" || $(this).val() == "Missing") {

    $("[name][name$='Quality']").attr('disabled', 'disabled');
    $("[name][name$='Age']").attr('disabled', 'disabled');
}

else {
    $("[name][name$='Quality']").removeAttr('disabled');
    $("[name][name$='Age']").removeAttr('disabled');
}
});

Your help will be much appreciated. The IDs for each element are dynamically generated, so I need the code to be able to adapt to include new ID, as users will have the ability to add new rows. The ID increases by one number for each row, so it should be easy to match Column1/Row1 (i.e. “Condition_1”) and Column2/Row1 (i.e. “Quality_1”). Thanks for your input.

  • 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-07T17:18:57+00:00Added an answer on June 7, 2026 at 5:18 pm

    I can’t believe how simple this solution actually was. I think my lack of sleep caused me to overlook the obvious. Anyway, here’s the answer to my own question…hope it helps someone 🙂

    $("[name][name $='Quality']").prop("disabled", true);
    
    $("[name][name $='Age']").prop("disabled", true);
    
    $("[name][name$='Condition']").change(function () {
    
    var parentDDL = $(this).closest('div');
    
    if ($(this).val() == "" || $(this).val() == "N/A" || $(this).val() == "Missing") {
    
        $("[name][name$='Quality']", $(parentDDL)).attr('disabled', 'disabled');
        $("[name][name$='Age']", $(parentDDL)).attr('disabled', 'disabled');
    }
    
    else {
        $("[name][name$='Quality']", $(parentDDL)).removeAttr('disabled');
        $("[name][name$='Age']", $(parentDDL)).removeAttr('disabled');
    }
    });
    

    I simply added a var that binds the action to the closest div containing the first DDL:

    var parentDDL = $(this).closest('div');
    

    Then I added the var into my if else statements:

     $("[name][name$='Quality']", $(parentDDL)).attr('disabled', 'disabled');
    

    If anyone has a more efficient suggestion, I am open to feedback. Thanks.

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

Sidebar

Related Questions

I am working on an ASP.NET MVC web app that allows people to publish
I have an iPad app that submits orders to an ASP.NET MVC web site
I have an asp.net MVC web app that processes images and resizes them which
While working on an ASP.Net MVC 3 web app I found the need to
Background I have a page on my ASP.NET MVC web app for users to
I'm new to web development and working on my first ASP.NET MVC 3 app.
I'm currently working on an Asp.net MVC Web application. In my solution, there're two
I am working on a sql server 2008 DB and asp.net mvc web E-commerce
I'm working my way through some ASP.NET MVC reading and I have a web
I've integrated ASP.NET MVC 3 project into existing Web Forms project. It was working

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.