Hi all,
Is it possible to rank a list of values in three columns in alphabetical order when outputting them as a checkbox list?
In other words: say I have a list of 12 values, and I would like to list them in three columns (always three columns) and I would like them listed alphabetically in a vertical way. Now, they are ranked, but horizontally. Is there an 'easy' way or not really?
Example:
Much like:
a - d - g
b - e - h
c - f - i
Instead of:
a - b - c
d - e - f
g - h - i
Rank checkboxes vertical ASC
Moderator: General Moderators
Re: Rank checkboxes vertical ASC
How easy is it depends on where the checkboxes are coming from. Simplest method would be if you have an array.
Say the array has X items in it. If you want them in three columns then there will be at most N=ceil(X/3) in each column: first column has 0 through (N-1), second column has N through (2N-1), third column has 2N through the end.
Since HTML works in a top-down fashion you need to print everything one row at a time (assuming you're using a table). The first row has #0, #N, and #2N. Second row has #1, #N+1, and #2N+1. Goes all the way until you're near the bottom of the table: the third column might not be complete so you need to check whether the item exists before trying to get it.
Should be enough to get you started.
Say the array has X items in it. If you want them in three columns then there will be at most N=ceil(X/3) in each column: first column has 0 through (N-1), second column has N through (2N-1), third column has 2N through the end.
Since HTML works in a top-down fashion you need to print everything one row at a time (assuming you're using a table). The first row has #0, #N, and #2N. Second row has #1, #N+1, and #2N+1. Goes all the way until you're near the bottom of the table: the third column might not be complete so you need to check whether the item exists before trying to get it.
Should be enough to get you started.