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

The Archive Base Latest Questions

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

I have a form with a checkbox. The checkbox, when checked, makes a table

  • 0

I have a form with a checkbox. The checkbox, when checked, makes a table (which is inside a div) hide and is replaced with a block of text that says they checked the box.

Inside that same div, there is a select box. If the user selects anything other than ‘——‘ some of the table rows hide and are replaced with some text saying they made a selection.

However, if the user first makes a selection and then checks the checkbox, the goal is to have the div hide the whole table and be replaced with only one block of text – namely the text that says you’ve checked the box.

Convoluted, ya, but for the project it makes sense.

So here’s some basic markup for clarity (some pseudo-code):

<checkbox input id="cBox">

<div id="myDiv">
  <table id="myTable">
    <select_box id="mySelect">
    <tr class="myTRClass">...some stuff...</tr>
    <tr class="myTRClass">...some stuff...</tr>
    <tr class="myTRClass">...some stuff...</tr>
  </table>

  <div id="replaceTable">
    ...some text telling user they checked the box
  </div>
  <div id="replaceRows" class="replaceMyRows>
    ..some text telling user they made a selection
  </div>
</div>

my jQuery for the select box (which should hide just the rows of the table). This code works:

t = $("#mySelect").val();
if (t == "") {
    $(".myTRClass").hide();
    $(".replaceMyRows").show();
}
else {
    $(".replaceMyRows").hide();
    $(".myTRClass").show();
}

Now, here’s my jQuery for the check box (this should hide the whole table):

    t = $( '#cBox' )
    if ($(t).attr('checked')) {
        $("#myTable").hide();
        $("#replaceTable").show();
    }
    else {
        $("#replaceTable").hide();
        $("#myTable").show();
    }

Now here’s my problem: These two sets of jQuery work fine on their own, but when I start to mix things together, I have problems.

For example: if I make a selection from the select box, the table rows hide and are replaced with my text. Perfect. But now, in this state, if I then check the check box to hide the whole table (which currently has some of its rows hidden) what I get is a hidden table, but both sets of text are present (The text saying “you made a selection” and the text that says “you checked the box”).

I can’t seem to get the right combo of .show() and .hide() to make this work. The result for my example should be: Hide the table, Hide the rows, Hide the text that says I hid the rows, then show the text that says I checked the checkbox.

Sorry if this is convoluted, it just seems an odd situation that should be straight forward.

Thanks for any help 🙂


Edit: Changed my title.


Edit #2

I’ve added a fiddle here
When it opens, the select box has ‘—–‘ chosen, so the table rows are hidden. Try selecting something else (rows show up). Try checking the box (whole table hides). However, try selecting ‘—–‘ FIRST then check the box – both texts show up. With this situation, I only want the “you checked the box” text to show up.

Ideas?

  • 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-15T19:52:39+00:00Added an answer on June 15, 2026 at 7:52 pm

    I am not sure here but seems like you should change your markup a little bit to manage.

    Here’s new html:

    <input type="checkbox" id="cBox">
    
    <div id="myDiv">
      <div class="hideByChkBx">
        <select id="mySelect" />
        <table id="myTable">
          <tr class="myTRClass">...some stuff...</tr>
          <tr class="myTRClass">...some stuff...</tr>
          <tr class="myTRClass">...some stuff...</tr>
        </table>
        <div id="replaceRows" class="replaceMyRows>
          ..some text telling user they made a selection
        </div>
      </div>
      <div id="replaceTable">
        ...some text telling user they checked the box
      </div>
    </div>
    

    Here is javascript:

    //For select box
    t = $("#mySelect").val();
    if (t == "") {
        $(".myTRClass").hide();
        $(".replaceMyRows").show();
    } else {
        $(".replaceMyRows").hide();
        $(".myTRClass").show();
    }
    
    //for checkbox
    t = $( '#cBox' )
    if ($(t).attr('checked')) {
        $(".hideByChkBx").hide();
        $("#replaceTable").show();
    }
    else {
        $(".hideByChkBx").show();
        $("#replaceTable").hide();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple form that has a checkbox. THe checkbox always appears checked
I have inserted this form with multiple checkbox items which collects some values, What
I have a checkbox that when it is clicked it submits the form to
I need to have a checkbox which ajax-submits a form. The following code throws
I have a checkbox group in one form that I need to be posted.
I have a Form with multiple different controls like ComboBox , TextBox and CheckBox
I have an HTML form: <form action='process.php' method='post'> <input type='checkbox' name='check_box_1' /> Check me!<br>
I have a checkbox with id terms and a submit button in my form
I have next code, <form id=form1 runat=server> <asp:Label runat=server ID=Label1 EnableViewState=false /> <asp:CheckBox runat=server
Suppose I have the following HTML: <form id=myform> <input type='checkbox' name='foo[]'/> Check 1<br/> <input

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.