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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:16:31+00:00 2026-05-16T03:16:31+00:00

I have a textbox control and a checkbox list control on my page. I

  • 0

I have a textbox control and a checkbox list control on my page.

I am first populating my checkbox list with a list of employee objects in the code-behind. An employee has an id and a name. Both are displayed in the checkbox list like so:

  • Jim (1)
  • Alex (2)
  • Gary (3)

When a user checks one of the boxes, the employee’s name needs to be populated in the textbox. So if Jim is selected, the textbox value is “Jim”. It also needs to support multiple values, so if Jim and Gary are selected, the textbox value is “Jim, Gary”.

Also, if a user enters a valid value in the textbox, the correct employee should be checked. This needs to support names and id’s. So if I enter “1,Alex” in the textbox and then click outside the textbox, Jim and Alex should be selected.

I’m using ASP.NET and I need to do this using AJAX, but I have no experience with using jQuery and AJAX. Could someone show me a simple example of how to do this?

  • 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-16T03:16:32+00:00Added an answer on May 16, 2026 at 3:16 am

    Here is something I through together that might help get you started. It’s not tested and not complete but I don’t have time to do it all right now, so thought this might help. There definitely needs to be a lot more checks and paring done that I left out for you to implement.

    $(function() {
        // gets all checkbox items by a common class you will put on all of them
        $('.checkboxlistclass').click(function(e) {
            var txt = $(this).text();
            var employeeName = txt; // change this to parse out the name part and remove the id
    
            var currentTxtVal = $('#textboxid').val();
            var newVal = currentTxtVal + ',' + employeeName; // check if you need the comma or not
    
            $('#textboxid').val(newVal);
        });
    
        // textboxid is the id of the textbox
        $('#textboxid').change(function(e) {
            var textboxVal = $(this).val();
    
            // split on the comma and get an array of items
            // this is dummy data
            var items = [];
            items.push('Jim');
            items.push(2);
    
            // go through all the items and check if it's a number or not
            // if it's a number do a selection based on the id in parenthesis
            // if not then check first part for name match
            for (var i=0; i < items.length; i++) {
                if (isNaN(parseInt(items[i])) {
                    $(".checkboxlistclass:contains('" + items[i] + " ('").attr('checked', true);
                }
                else {
                    $(".checkboxlistclass:contains(' (" + items[i] + ")'").attr('checked', true);
                }
            }
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

have a TextBox item (MyTextBox) on a TabItem control. I have code that looks
I have a list of Controls that are held in a List<Control> and I
I have a custom user control DatePicker.cs. Inside of another piece of code I
I have a form with about 40 checkboxes. Once a checkbox is checked, the
I have a group of usercontrols that I use multiple instances of through out
It's fairly straightforward. I want to set focus to the first enabled and not
i am using a calendar extender control in my asp.net web application. i want
I'm using a DetailsView in an applicaoon I am developing, and have a minor
My standalone Windows app. is written on C# 2008 and back-end is MySQL 5.1.
why CSS rules do not cascade down automatically to HTML controls like input or

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.