I was wondering how I could dynamically display columns and rows based on the target amount.
Let me clarify this more clearly.
I have a javascript array called groepsCodes.
I want to make a bootstrap column for each of these group codes.
The problem is that I only want four columns per row, so if I have 5 group codes I would like 4 columns in one row and 1 column in the next row.
More ideally would be 3 columns & 2 columns, but that's an issue for later.
I feel like this is the point where my javascript knowledge stops, so if anyone knows what to do, I'd be glad to hear it.
Edit:
As suggested I should add code.
In my HTML I have these divs that need to be filled:
<div id="groupCharts">
<div class="row" id="groupChartsRow">
</div>
</div>
In javascript I do that as such:
groepsCodes = ["test", "test1", "test2", "test3"];
for (i = 0; i < groepsCodes.length; i++) {
$("#groupChartsRow").append("<div class='col'><div class='chartCard'>Hoi</div></div><br>");
}
Now this works fine. But let's say groepsCodes has 5 items instead of 4.
Now I'd like an extra row div, how could I solve this?