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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T07:27:53+00:00 2026-05-14T07:27:53+00:00

Hi i am trying to create dropdownlists dynamically and populating the contents via an

  • 0

Hi i am trying to create dropdownlists dynamically and populating the contents via an ajax call, this sort of works in the sense that the drop down is created and populated as required but its ‘change’ event does not fire. I am posting the code below, if anyone can spot something obvious, can you please let me know
regards

$(document).ready(function () {

 $("#positions select").change(function (e) {
    alert("in");
    var id = $("#category_id").val();
    $.getJSON("/Category/GetSubCategories/" + id, function (data) {
    if (data.length > 0) {

        alert(data.length);
        var position = document.getElementById('positions');
        var tr = position.insertRow(7);
        var td1 = tr.insertCell(-1);
        var td = tr.insertCell(-1);
        var sel = document.createElement("select");
        sel.name = 'sel';
        sel.id = 'sel';
        sel.setAttribute('class', 'category');

        td.appendChild(sel);
        $.each(data, function (GetSubCatergories, category) {
        $('#sel').append($("<option></option>").
       attr("value", category.category_id).
      text(category.name));

        });
    }
    });
    });
 }); 
  • 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-14T07:27:54+00:00Added an answer on May 14, 2026 at 7:27 am

    If your drop down is dynamically generated then you have to bind the change event using .live() handler. live() attaches a handler to the event for all elements which match the current selector, now or in the future.

    $("positions select").live("change", function(){
    });
    

    Edit

    To get the id

    $(this).attr("id");
    

    To get value

    $(this).val();
    

    To get class name

    $(this).attr("class");
    

    inside the change event handler.

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

Sidebar

Related Questions

I'm trying to create some cascading drop downs. I have my States loading via
I am trying to create a UI that creates rows that can be dynamically
Trying to create a background-image slideshow and am getting this error... This is the
I was trying to create a custom combobox that inherited from ComboBox, but I've
I'm trying create a box in my Django app that displays text (and possibly
I'm trying create a ASMX webservice that can perform a HTTP GET request. I
I am trying to create a dynamic UI using UpdatePanel of AJAX toolkit. Let
Hey guys. I'm working in WinForms and trying to create a ComboBox control that
What I am trying to do is dynamically create a bunch of dropdown lists
I'm trying to create a web page that will display an appropriate user control

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.