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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:29:36+00:00 2026-06-06T04:29:36+00:00

I have this long list of checkboxes with specific labels that look something like

  • 0

I have this long list of checkboxes with specific labels that look something like this:

<input type='checkbox' name='check[]' id='159' value='159' />
<label for='159'>Person 1</label>

<input type='checkbox' name='check[]' id='160' value='160' />
<label for='160'>Person 2</label>

And below this form I have six div’s like so:

<div id="member1" class="member"></div>
<div id="member2" class="member"></div>
<div id="member3" class="member"></div>
<div id="member4" class="member"></div>
<div id="member5" class="member"></div>
<div id="member6" class="member"></div>

Someone helped me write this JS function so that when I click on a checkbox, it’s label is inserted into the first div. Here’s what it looks like:

$(function(){
$('#159').click(function(){
    if($(this).is(':checked')){
        $('#member1').text($('label[for="159"]').text());
    }
    else{
        $('#member1').text('');   
    }
});
});

The problem is I don’t know how to edit this function to work for any checkbox that’s clicked. Currently it only works on the checkbox with an id of 159. The second problem is the function specifies what div to put it into. The idea is that when the first div is “full”, the next checkbox will insert the label into the second div, and then the third, etc.

Please note that if the checkbox is unchecked, the label is removed from the div, and the labels in the divs below it would have to move up. Anyone know if this is possible?

  • 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-06T04:29:39+00:00Added an answer on June 6, 2026 at 4:29 am

    Try this.

    Live Demo

       $(function() {
    
        $('input[type=checkbox][name=check\[\]]').click(function() {
            chkboxid = $(this).attr('id');
            if ($(this).is(':checked')) {
    
                $('#member' + eval($(this).index() + 1)).text($('label[for="' + chkboxid + '"]').text());
    
            }
            else {
                $('#member' + eval($(this).index() + 1)).text('');
            }
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this long list of checkboxes with specific labels that look something like
I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth=200
I have fancy looking jQuery Multiple checkbox/selectbox list script. Look HERE for demo. This
Hopefully this is simple: I have a relatively long list where each list item
This is a long shot, I know... Let's say I have a collection List<MyClass>
In Android 3.0 (Honeycomb) we have this feature that when we long press any
I have a long list of checkboxes bound in a repeater is there a
I have a long list of checkboxes each with a link next to it.
I have this long query that I finally got to work but I am
For classes that have a long list of setters that are used frequently, I

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.