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

  • Home
  • SEARCH
  • 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 3431292
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:18:28+00:00 2026-05-18T07:18:28+00:00

I have multiple tables on my page that contain a checkbox. Immediately following the

  • 0

I have multiple tables on my page that contain a checkbox. Immediately following the table is a div that by default is hidden. I want to show/hide the div depending on the checkbox selection.

Since I have about 10 of these structures, I want to figure out a way to create one click selection to handle any one that is clicked.

The HTML:

<table>  
<input id='cbChecklist1'>  
</table>

<div id='divChecklist1'>  
Show/Hide  
</div>

So I have cbChecklist1-cbChecklist10 and divChecklist1-divChecklist10. When a checkbox in the tab that has cbChecklistX I want it to show/hide the corresponding divChecklistX.

Thanks!

@@@@@@@@@@@@@@@@@@EDIT@@@@@@@@@@@@@@@@@@

I’ve changed the design of my checkboxes and tables and I’m trying to use the slideDown, slideUp methods, but it doesn’t seem like I’m properly selecting my proper <div> — at least it is not sliding the <div> up and down.

2 Questions:
1. Am I properly modifying the <div> selector?
2. How do I debug this to know how the selection is working?

Updated HTML:

<table>  
<input id='cbPressueChecklist'>  
</table>

<div id='divPressueChecklist'>  
Show/Hide  
</div>


<table>  
<input id='cbMechanicalChecklist'>  
</table>

<div id='divMechanicalChecklist'>  
Show/Hide  
</div>

My jQuery Code:

$('input[id$=Checklist]').change(function()  
{  
    var divId = '#div' + this.id.substring(2);  
    if (this.checked)  
        $(divId).slideDown(1500);  
    else  
        $(divId).hide(1500);  
});

Again, thanks.

  • 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-18T07:18:29+00:00Added an answer on May 18, 2026 at 7:18 am
    $('input[id^=cbChecklist]').change(function() {
        var divId = '#divChecklist' + this.id.match(/\d+$/)[0];
        $( divId ).toggle( this.checked );
    });
    

    This binds a .change() event handler to <input> elements where the ID attribute starts with cbChecklist.

    When a change event occurs, it extracts the number from its ID, and concatenates it to #divChecklist to create the selector.

    Then .toggle() is called on the related <div>, passing this.checked as a switch so that if the box is checked, it will show the <div>, otherwise it will hide.

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

Sidebar

Related Questions

I have a site with multiple pages, and each page has a table that
I want to have a php page that display multiple keywords (checkboxes) for example
I have multiple tables that need to be merged into one. SELECT name, SUM(money)
I have a dataset with multiple tables. One table in particular has one record
I have a query that displays columns from multiple tables in a test dbase.
I have the following scenario: 1) A phone book table 2) Multiple ways of
I have a multiple html tables on a page which each have a header
I have a PHP script that shows multiple tables of data loaded via a
$('table.listings td:contains(You)').each(function(){ $(this).children('td:nth-child(2)').addClass('highlighted'); }); I have multiple table.listings on the page but the one
I've got an iOS app that has a page view to show multiple items

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.