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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:35:43+00:00 2026-06-04T10:35:43+00:00

I think this will be a really easy one for anyone that is decent

  • 0

I think this will be a really easy one for anyone that is decent with jQuery, but I’ve got dynamically generated dropdownlists on my page, and I’ve set up a click event on the class, which, as expected fires a click event for all of them. The ID of the select is dynamically generated, so I can’t use that as the selector. I just want to fire the event for the select that is actually changed.

I need to use the id of the selected value in the function – anyone know how this is done?

Code I have so far:

$(document).ready(function () {
    $(".boxItem").change(function () {
        var str = $(this).attr('id');
        var num = $(this).val();
        alert(num);
        var url = "/Search/GetBoxChangeInfo";
        var vmData = { json : @Html.Raw(Json.Encode(Model)),
                        id : str,
                        boxNo : num };
        $.post(url, vmData, function (data) {
            $("#column-1").html(data);
        });
    });
});

Many thanks

  • 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-04T10:35:44+00:00Added an answer on June 4, 2026 at 10:35 am
    $(".boxItem").on("change", function () {
    
        // to get the value and id of selected option
        var str = $('option:selected', this).attr('id');
        var value = $('option:selected', this).attr('value');
    
        // or to get value and id of select box use
        var str = this.id; 
        var value = this.value;
        ......
    });
    

    If you select is live i.e created after DOM ready then you should try

     $("body").on("change", ".boxItem", function () {
    
        // to get the value and id of selected option
        var str = $('option:selected', this).attr('id');
        var value = $('option:selected', this).attr('value');
    
        // or to get value and id of select box use
        var str = this.id; 
        var value = this.value;
        ......
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hopefully this will be an easy one for anyone with any Django experience. I'm
This is a really easy one that I thought would be easily found on
Do you think that C# will support something like ??= operator? Instead of this:
I have this thing that i need to do and some advices will be
I think this is likely to be a generic .NET assembly loading question, but
I think this is a simple question, but I can not find the answer
I'm dealing specifically with C++, but this is really language-agnostic. Just to give some
Well, I think YAML is really fantastic... It's beautiful, easy to read, clever syntax...compared
I know there should be an easy way to do this but I guess
Thank you so much for reading this! I think the fix is relatively easy,

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.