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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:00:14+00:00 2026-05-10T21:00:14+00:00

Thanks for reading this. I am dynamically generating some data which includes a select

  • 0

Thanks for reading this.

I am dynamically generating some data which includes a select drop-down with a text box next to it. If the user clicks the select, I am dynamically populating it (code below). I have a class on the select and I was hoping the following code would work. I tested it with an ID on the select and putting the ONE on the ID I got it to work. However, in changing the code to reference a class (since there will be multiple data groups that include a select with a text box next to it) and $(this), I could not get it to work. Any ideas would be helpful. Thanks

The relevance of the text box next to the select is the second part of the code…to update the text box when an option is selected in the select

.one is so the select is updated only once, then the .bind allows any options selected to be placed in the adjacent text box.

$('.classSelect').one('click',  function() {   $.ajax({    type: 'post',    url: myURL ,    dataType: 'text',    data: {     '_service' : myService,     '_program' : myProgram ,     'param' : myParams    },    success:     function(request) {      $(this).html(request);   // populate select box    }    // End success   }); // End ajax method    $(this).bind('click',    function() {     $(this).next().val($(this).val());   }); // End BIND  }); // End One   <select id='mySelect' class='classSelect'></select>  <input type='text'> 
  • 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. 2026-05-10T21:00:14+00:00Added an answer on May 10, 2026 at 9:00 pm

    $(this) is only relevant within the scope of the function. outside of the function though, it loses that reference:

    $('.classSelect').one('click', function() {    $(this); // refers to $('.classSelect')     $.ajax({    // content       $(this); // does not refer to $('.classSelect')    }); }); 

    a better way to handle this may be:

    $('.classSelect').one('click', function() {     var e = $(this);      $.ajax({     ...         success : function(request) {           e.html(request);         }     }); // end ajax      $(this).bind('click', function() {     // bind stuff      }); // end bind  }); // end one 

    by the way, are you familiar with the load() method? i find it easier for basic ajax (as it acts on the wrapped set, instead of it being a standalone function like $.ajax(). here’s how i would rewrite this using load():

    $('.classSelect').one('click', function() {     var options = {        type : 'post',        dataType : 'text',        data : {          '_service' : myService,          '_program' : myProgram ,          'param' : myParams        }                } // end options      // load() will automatically load your .classSelect with the results     $(this).load(myUrl, options);       $(this).click(function() {     // etc...      }); // end click  }); // end one 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 92k
  • Answers 92k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Yes it is indeed possible to add a link to… May 11, 2026 at 6:22 pm
  • Editorial Team
    Editorial Team added an answer OK I figured it out. Amazon's EC2 has it's own… May 11, 2026 at 6:22 pm
  • Editorial Team
    Editorial Team added an answer Nazadus, Is this what you are looking for? LINQ to… May 11, 2026 at 6:22 pm

Related Questions

I am presenting to a final authority evaluation scores for employees. Each row is
Thanks for reading this. I am using a shared service (server=sharedLib) when setting up
Thanks for reading this. I would have thought it would be as simple as
Thanks for reading this. I imagine this is really a javascript question, and my

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.