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

The Archive Base Latest Questions

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

i want to use jquery’s function on dropdownlist’s OnTextChanged Event. but i dont know

  • 0

i want to use jquery’s function on dropdownlist’s OnTextChanged Event. but i dont know why its not firing. my code is,

    <asp:GridView ID="grd_test" runat="server" Style="text-align: center;
                width: 375px;" AutoGenerateColumns="false">

                <Columns>

                    <asp:TemplateField HeaderText="Test">
                        <ItemTemplate>
                            <asp:DropDownList ID="drp_test"  OnTextChanged='<%# "return CheckVal(this);" %>' runat="server">
                                <asp:ListItem Value="">0</asp:ListItem>
                                <asp:ListItem Value="1"> 1</asp:ListItem>
                                <asp:ListItem Value="2">2</asp:ListItem>
                                <asp:ListItem Value="3">3</asp:ListItem>
                            </asp:DropDownList>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>

my javascript’s code is

    function CheckVal(obj) {
        var collection = document.getElementById(obj.parentNode.id).getElementsByTagName('SELECT');

        for (var x = 0; x < collection.length - 1; x++) {
            if (collection[x].type.toUpperCase() == 'SELECT-ONE') {
                alert(collection[x].value);
            }

}
}

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

    Putting aside the fact that I can’t see any jQuery on the code sample you’ve provided, the select element (i.e. your DropDownList object) uses an OnChange event, not OnTextChanged. If you want something to fire when the user changes the selection this is probably why you’re not seeing anything.

    Given you have a number of tables, each containing a set of select elements, you’re going to want to listen for any change to a given table’s select boxes. Here’s how you would monitor the change event for each individual table in your repeated gridviews:

    $('table[id$=drp_test]').each(function(){
    
       $('select', this).change(function(){
          console.info($('option:selected', this).text());
       });
    
    });
    

    This looks at each table on your page whose element ID ends with “drp_test” and adds an event handler to all its select elements.

    Now we need to modify this to check the other values from the changed select element’s siblings. The end result is that we need to ensure each of the selected options for that table’s group is unique.

    $('table[id$=drp_test]').each(function () {
    
        var selects = $('select', this);
    
        // For each select...
        selects.each(function () {
            // Whenever one changes, fire this event
            $(this).change(function () {
    
                // Gather all the chosen options from this group
                var arr = $.map($('option:selected', selects), function (n) {
                    return n.value;
                });
    
                // And calculate how many unique values we find.
                console.info("The number of duplicated values is " + (arr.length - ($.unique(arr).length)));
            });
        });
    
    });
    

    The end result is that you get a count of how many non-unique selected values you have in each table.

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

Sidebar

Related Questions

I want to use jQuery's great live functionality for a mouseenter event, but it's
I want to use jQuery function to fetch web service response but getting error
First off: I do not want to use JQuery, i know it would make
I want to use jQuery with a GridView which contains textboxes, but I'm stuck
I want to use jquery Chili plugin for syntax highlighting a piece of code
I don't want to use jQuery, but I'd like to use Ajax to do
I already started this in javascript so I don't want to use jquery but
I want to use jQuery Thickbox for displaying my images but so far when
I want to use jQuery.getJSON function in ASP.NET MVC 3.0, so I wrote the
I want to use jquery's (.load) function in CI, should i place this jquery

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.