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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:58:37+00:00 2026-06-14T13:58:37+00:00

I am using jquery to get the value of a checkbox. However, what is

  • 0

I am using jquery to get the value of a checkbox. However, what is happening is that the value is getting duplicated and seems to be getting values for all checkboxes in the while loop. I would be grateful if someone could point out my error. Thank you.

UPDATE: Current code. Now only selecting first entry. No output on further checkbox clicks.

PHP Code

while($row = mysql_fetch_array($result)) 
{
    $ticket = $row['ticket_frm'];
    $rowdate = date("d/m/Y",strtotime($row['date_frm']));
    $id = $row['id_frm'];
    $from = $row['from_frm'];
    $subject = $row['subject_frm'];
    $message = $row['message_frm'];

    $myString = <<<EOF
    <span><input id="check" type="checkbox" name="delete" value="<?php echo $ticket ?>"></span>
    <div class='msgTrue buttonMailTrue' data-message='%s' data-subject='%s' data-rowdate='%s' data-from='%s'>

    <img src="images/sml_new_mail_icon.gif" class="mailIcon" alt="" />$subject;
    <div class="rowdate">$rowdate</div><br />
    <span class="mailFrom">$from</span>
    </div>
    <p class="checked"></p>
    <!-- The following end tag need to be at the start of the line -->
    EOF;
    printf($myString, $message, $subject, $rowdate, $from);
}   echo '<p class="checked">'.'</p>';

jQuery Code

$(function() {
    $("#check").click(function() {
       var isChecked = $(this).prop("checked");  // or $(this).prop("checked")
         if (isChecked) {
           $("p.checked").html("Checkbox is checked: <b>True</b>");
       } else {
           $("p.checked").html("Checkbox is checked: <b>False</b>");
}

});
});

  • 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-14T13:58:38+00:00Added an answer on June 14, 2026 at 1:58 pm

    According your code and selectors, there are many input class="check" elements on your page.
    You find them by class name, so this is why they are duplicate.

    Use id-attribute and $("#id") syntax to get right values, or use this keyword in your code:

    //var isChecked = $('.check').is(':checked'); - wrong
    var isChecked = $(this).is(':checked'); // right
    

    Update:
    You didn’t provide unique id for your elements. Of cause this doesn’t work. Your error is the same as earlier.
    Try this code:

    <input id="check$ticket" type="checkbox" name="delete" value="<?php echo $ticket ?>">
    

    Same for javascript – you have to find element by it’s unique id

      $("#check" + TICKET_NUMBER_HERE).click(function() {
       var isChecked = $(this).prop("checked");  // or $(this).prop("checked")
         if (isChecked) {
           $("p.checked").html("Checkbox is checked: <b>True</b>");
       } else {
           $("p.checked").html("Checkbox is checked: <b>False</b>");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get the values of all checkboxes that are currently checked using
I have a checkbox, how do I get its value using jquery? I have
I'm using a method as explained here: http://iamcam.wordpress.com/2008/01/15/unchecked-checkbox-values/ to get a value even if
How can I get the values of checkboxes which are selected using jQuery? My
I'm trying to get the value of a form field on submit using jQuery.
I've a field in the form,trying to get this value using jquery.It is always
Is it possible to get a particular value out of viewstate using JQuery.... I'm
Using jQuery, how can I get the selected item's value in a select when
How to get the parameter value from the URL using Javascript or Jquery whatever
I am using ASP.NET page methods with jQuery.... How do I get the value

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.