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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:05:13+00:00 2026-06-15T18:05:13+00:00

I am having an issue trying to get a hold of a cascading combo

  • 0

I am having an issue trying to get a hold of a cascading combo box on the outer combo box change event. you can add and remove rows from a table so there could be any number of rows. Inside each row are 2 combo boxes. 1 is for customer and 1 is for contact. I have a change event firing on customer combo box that goes and pulls the valid contacts for that customer. Below is the html for the table

<tr class="ClassAttendee">      
<td>
    <select class="Customers valid" id="Attendees_0__Customers"
    name="Attendees[0].Customers">    
        <option value="1517">Woodstock</option>
        <option value="1518">Woolwich</option>
        <option value="1519">Yarmouth</option>
        <option value="1520">York</option>
    </select>
</td>
<td>
     <select class="Contact">
         <option value="">Choose Attendee...</option>
     </select>
</td>
<td>
     <input data-val="true" data-val-required="The Attended field is required."
     id="Attendees_0__Attended" name="Attendees[0].Attended" type="checkbox"
     value="true"><input name="Attendees[0].Attended" type="hidden" value="false">
     <span class="field-validation-valid" data-valmsg-for="nestedObject.Attended" data
     -valmsg-replace="true"></span>
</td>
<td>
     <input class="FeePaid" data-val="true" data-val-required="The Fee Paid field is
     required." id="Attendees_0__FeePaid" name="Attendees[0].FeePaid" type="checkbox"
     value="true"><input name="Attendees[0].FeePaid" type="hidden" value="false">
     <span class="field-validation-valid" data-valmsg-for="nestedObject.FeePaid" data
     -valmsg-replace="true"></span>
</td>
<td>
     <input class="CheckNumber" id="Attendees_0__CheckNumber"
     name="Attendees[0].CheckNumber" type="text" value="">

     <span class="field-validation-valid" data-valmsg-for="nestedObject.CheckNumber"
     data-valmsg-replace="true"></span>
</td>
<td>
    <input class="mark-for-delete" data-val="true" data-val-required="The Delete field
    is required." id="Attendees_0__Delete" name="Attendees[0].Delete" type="hidden"
    value="False">

    <a href="#"
    onclick="javascript:removeNestedForm(this,'tr.ClassAttendee','input.mark-for
    -delete');return false;">Remove</a>
</td>
</tr>

Each row looks like this where the first 2 cells contain drop downs. The first for Customer and the second for Contacts. If I just use a selector of $(“Contact”) I can update the combo boxes with the correct options so I know this works but I need to specify the row because when I just use that selector all rows get updated.

?Below is the JQuery I am trying to use

 $('.Customers').change(function (e) {
        var selectedCustomer = $(this).val();
        if (selectedCustomer != null && selectedCustomer != '') {
            $.getJSON('@Url.Action("GetAllSelectedCustomer", "CustomerEmails")', { id: selectedCustomer }, function (contacts) {
                var contactSelect = $(this).parent().next().children(".Contact");
                contactSelect.empty();
                $.each(contacts, function (index, contact) {
                    contactSelect.append($('<option/>', {
                        value: contact.ID,
                        text: contact.Name
                    }));
                });
            });
        }
    });

The speicif line I am having issues with is

var contactSelect = $(this).parent().next().children(".Contact");

If I use a selector to first select the customer drop down box instead of using this and then use the rest of the line I can select the contacts drop down. I don’t understand why this is not working and I also have no ideas on how to select the specific drop down list on the row I am dealing with for the change event if I can’t use the this object.

Any ideas would be greatly appreciated.

  • 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-15T18:05:16+00:00Added an answer on June 15, 2026 at 6:05 pm

    Try using a closure:

    $('.Customers').change(function (e) {
        var selectedCustomer = $(this).val();
        if (selectedCustomer != null && selectedCustomer != '') {
            (function(el) {
                $.getJSON('@Url.Action("GetAllSelectedCustomer", "CustomerEmails")', { id: selectedCustomer }, function (contacts) {
                    var contactSelect = $(el).parent().next().children(".Contact");
                    contactSelect.empty();
                    $.each(contacts, function (index, contact) {
                        contactSelect.append($('<option/>', {
                            value: contact.ID,
                            text: contact.Name
                        }));
                    });
                });
            })(this);
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having an issue trying to get the number of rows from a
The issue I'm having is issue with is I'm trying to get the paintComponent
I'm having an issue here, I am trying to get all the titles from
I'm having an issue trying to get an accurate running total for my calculations.
We're having an issue trying to chain selectors together. We are trying to get
i am having a issue with treeview liststore trying to get a real-time update,
I'm having an issue trying to get my SQL query which works fine in
I'm having an issue trying to get a Facebook feed dialogue fb.ui to display
I am having an issue trying to get my affiliate tracking pixels to mark
I am having an issue in trying to get the 2 product ul items

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.