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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:52:26+00:00 2026-06-15T09:52:26+00:00

I have a set groups with a checkbox, I am trying to get the

  • 0

I have a set groups with a checkbox, I am trying to get the value of each checkbox when is checked and appending this value to a counter span element i have next to it, but every time i click on any of the checkboxes is appending the value to all the counter elements. I created a http://jsfiddle.net/creativestudio/xm838/

This is the Js I am using:

function set_index_id_checkbox() {
    $("input:checkbox[name='like']").each(function (index) {
        var currElem = $(this);
        var prevLabel = currElem.next();
        currElem.attr("id", this.id + index);
        prevLabel.attr("for", prevLabel.attr("for") + index);
    });
}

set_index_id_checkbox();

function getValues() {
    $("input:checkbox[name='like']").click(function () {
        if ($(this).is(':checked')) {
            $('.likes').html($(this).val());
        }
    });
}

getValues();
  • 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-15T09:52:27+00:00Added an answer on June 15, 2026 at 9:52 am

    That’s because you are selecting all the elements with class of likes, you can use prev and find or closest methods for selecting the target element.

    $(this).parent().prev().find('.likes').html(this.value);
    

    or:

    if (this.checked) { // better than creating an unnecessary jQuery object
       $(this).closest('.block').find('span.likes').text(this.value);
    } else {
      // ...
    }
    

    http://jsfiddle.net/Ud9T4/

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

Sidebar

Related Questions

I'm coding this plugin that validates if a series of checkbox groups have at
I have set of points (matrix Nx1) and groups for this points (matrix Nx1)
I am trying to build a TreeView and have it set up like this
What am I doing wrong? I have the () to set up two Groups,
I have a set of data that is structured like this: ItemA.GroupA ItemB.GroupA ItemC.GroupB
Possible Duplicate: Retrieving the last record in each group I have two tables set
I have set a background on the data-role=page element like so <div data-role=page style=background:
I have set of flat files (114 files) each file is named with database
Ok, the first column in my datagridview is a checkbox. I have 'multiselect' set
I have a simple user signup form with a checkbox that lets users get

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.