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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:51:14+00:00 2026-05-27T08:51:14+00:00

I have two grids, they both display buttons. One grid displays numbers, true or

  • 0

I have two grids, they both display buttons. One grid displays numbers, true or false and yes or no, and the other grid displays letters, true, false, yes and no.

The second grid is not displayed in the code (used css to not display second grid buttons (.answerBtns)).

Now I have included this in my code:

var clickedNumber = 10;
$('.answerBtns').each(function (index) {
    if (index < clickedNumber) {
        $(this).show();
    }
});

Now what this does is no matter how which button I select in the first grid, it will always display 10 buttons. So what I need is clickNumber to be in a loop so it loops through the buttons, so if the user selects button “1” in first grid (the grid which you have to open using (Open Grid) link, then it should display the first button which is “A” in second grid, if user selects button “2” in first grid, then it should display the first two buttons “A” and “B” in second grid, if “3” then display “A”, “B” and “C” and so on.

But also if user selects “True or False” button in first grid, it should display only “true” and “false” buttons in second grid and if user selects “yes or no” button in first grid, it should display “Yes” and “No” buttons only in second grid.

Does anyone know how to do this?

Thank you

Code is in jsfiddle, click here

  • 1 1 Answer
  • 3 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-27T08:51:15+00:00Added an answer on May 27, 2026 at 8:51 am

    If you add the following to the end of your buttonclick() function it will show or hide the appropriate number of buttons, as you can see in this updated jsfiddle.

    $('.answerBtns').each(function (index) {
       if (index < button.value)
          $(this).show();
       else
          $(this).hide();
    });
    

    Note that that is basically the same as the snippet from your question except using the value from the clicked button instead of a hardcoded 10.

    But more generally, if you’re using jQuery then use jQuery. That is, don’t put inline onclick handlers in every one of your buttons. They all just say onclick="buttonclick(this);", and they all have the same class, so you should remove those inline handlers from your HTML and set them up using jQuery.

    So you could replace your buttonclick function with something like this:

    $(".gridBtns").click(function() {
       // what you need from your "buttonclick(button)" function should go here
       // except instead of the "button" parameter you can just use "this",
       // e.g., this.value
    
       var clickedNumber = this.value;
    
       $('.answerBtns').each(function (index) {
          if (index < clickedNumber)
             $(this).show();
          else
             $(this).hide();
       });
    
    });
    

    I haven’t got time to do the “yes or no” part for you, but perhaps you can figure it out from the above? Within the click handler you can test if (this.value==="yes or no") and so forth.

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

Sidebar

Related Questions

I have two grids, thay both have one store. I need to show everything
I have two grid, one with auto-generated fields and the other not. how can
I have two different grid controls on the same form. They share the same
I have two grids with same number of rows ( also same height). Both
I have two tables on my page and they appear side-by-side. The first one
I have two forms, one to edit room details and the other to edit
In .net objects like DataTable when you have two grids(Master and Detail) and add
We have two textBlocks like this: (we used .NET FW 3.0) <TextBlock Grid.Column=0 Name=tabName
I have a grid view that has two simple columns, a report number and
Hi I have a grid of around 30 cells each with two images, a

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.