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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:41:41+00:00 2026-05-25T01:41:41+00:00

I am populating an element with some html: table, checkboxes. I have an onclick

  • 0

I am populating an element with some html: table, checkboxes.
I have an onclick event in my checkbox, but the page doesn’t seem to be listening to the click event. I suspect it’s because it was loaded after the javascript checkall() function got put into the DOM.

Here’s what I have:

<select name="showcuslist" id="showcuslist">
  <option value="0">select a customer</option>
  <option value="1">John Smith</option>
  <option value="2">Jane Smith</option>
</select>

<div id="loadtables">---ajax loads stuff into here---</div>

<script language="javascript" type="text/javascript">
$(document).ready(function(){ 

  $("#showcuslist").change(function(){
   $.ajax({
     data:"formId=grabcusinfo&cusid="+$(this).val(),
     success:function(response){ eval(response); } 
   });
  });


});

function checkall(){
  $(".checkboxes").attr("checked",true);
}
</script>

Simply, when I get to this page I can select a customer from the dropdown menu. Nothing too complicated.
Jquery then calls a page on the server for the purpose of grabbing some info about that customer.
The info is actually a list of Notes, so nothing huge. But I format the notes into an html table.

The first column in that html table has checkboxes, corresponding to each Note record.
I also put a Master Checkbox in the top, so if I check that box, all boxes will be checked.

The html table loads fabulously, however, that master checkbox isn’t working.

Here’s the html table I load into the

<?php
    $alltables='<table>';
    $alltables.='<tr>';
      $alltables.='<th><input type="checkbox" id="checkall" class="checkall" onclick="checkall();" /></th>';
      $alltables.='<th>Notes Title</th>';
    $alltables.='</tr>';

    $alltables.='<tr>';
      $alltables.='<td><input type="checkbox" id="someID" class="checkall" /></td>';
      $alltables.='<td>Notes Title Text...</td>';
    $alltables.='</tr>';
    $alltables.='</table>';

    $("#loadtables").html("'.addslashes($alltables).'");
?>

The checkall(); function works fine if I load the table when the page loads, but not when I load a new table with new data.

I’ve been told this is where live() or bind() helps out, but I’m honestly not understanding the jquery docs.

  • 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-25T01:41:42+00:00Added an answer on May 25, 2026 at 1:41 am

    Using .bind() will bind to an event for all matching DOM elements that exist at the time that the bind function was called. Using .live() will bind to all matching DOM elements that exist at the time of the method call and any matching DOM elements that get added dynamically in the future.

    So, if you are adding elements that you want to run some jQuery against, you should use .live() to automatically bind the event handler function to those elements as they are added.

    Since you are writing out <input type="checkbox" id="checkall" class="checkall" onclick="checkall();" /> as part of the table, I would modify your code to this:

    1. remove the onclick attribute from the input element.

      <input type="checkbox" id="checkall" class="checkall" />
      
    2. add the click handler using the live function

      $(".checkall").live("click", function() { checkall(); });
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple page (index.html) with a div: I am populating that div
im populating the data in the combo box using dataset tables...with some table name..now
I have a SELECT element in a form which I'm populating using AJAX when
I am populating a Select form element, and if I try to use HTML
I'm confused as to how to accomplish this. I have a page which, has
Quick question, looking for some recommendations. I have a site that will be requesting
I have a list and I am trying to find a particular element and
I've found some results for this on google but nothing satisfying so I was
I am cloning a hidden table row then populating it and after validation I
I'm populating a stack instance variable with elements of the array el , but

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.