checkbox value displaying twice

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>
    <p class="checked"></p>
    <!-- The following end tag need to be at the start of the line -->
    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>");


Leave a Reply


Hire Me
Follow Me!
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.