I want a more efficient way of coding to not display buttons

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 using the getButtons() function, if the user selects button “1” in first grid (the grid which you have to open using (Open Grid) link, then it should display button “A” in second grid, if user selects button “2” in first grid, then it should displays buttons “A” and “B” in second grid, if “3” then display “A”, “B” and “C” and so on.

Now except using if statements and stating which buttons should be displayed and not displayed depending on the button chosen in first grid, is there a more efficent way of coding this so that the display of buttons in second grid depends on what is selected in the first grid?

If it is using an array can somebody show a sample of this in their answer. You can just do it for one example and then I should be able to use that to fill it for the other buttons.

Thank you

Code is in jsfiddle, click here

It sounds like a simple for loop will do the job there for you.

You can have an area for that second grid just as an empty div:

<div id="grid2"></div>

and when an option is chosen, you can use a loop to create the buttons that you need:

var $grid2 = $('#grid2'),
for (i = 0; i < this.value; i += 1) {
    $grid2.append('<button>' + (i + 1) + '</button>');

You may also want to hide that second grid when the “open grid” link is clicked too.