Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 385
  • Last Modified:

Jquery check value change across multiple Dropdownlist

I wanting to know is it possible to check the change of like Dropdownlist in one jquery function.
Currently I can check the change of one or another control, ie.   $('#<%= Allergies1DDL.ClientID %>').change(function () {... and then do the same for    $('#<%= Allergies2DDL.ClientID %>').change(function () {...  

But I would like to combine the change event to listen for change using an OR operator like,
 $('#<%= Allergies1DDL.ClientID %>' || '#<%= Allergies2DDL.ClientID %>').change(function () {...

Is this possible?  When I run the program the first item is only works.



//This section checks DropdownList on change if 'Other' has been selected if it has then Open Jquery UI and allow user to add item.
    $(document).ready(function () {
        $('#<%= Allergies1DDL.ClientID %>').change(function () {
            var aDDL = $(this).val();
            if (aDDL == "-1") {
                //Open Jquery Dialog             
                addDDLOpenDialog(-1, "Allergies");
            }
        });
    });

Open in new window

0
Robert Treadwell
Asked:
Robert Treadwell
1 Solution
 
jagssiduralaCommented:
instead of assigning change event with id, assign by css class as below.

Step1 : Give a dummy Css class called "Select"(can define yourself) to each dropdown

Step2: Change above script as below

        $('.Select').change(function () {
            var aDDL = $(this).val();
            if (aDDL == "-1") {
                //Open Jquery Dialog            
                addDDLOpenDialog(-1, "Allergies");
            }
        });


0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now