For data storage, I'd say you want three tables, one for the items
across the top of the matrix, one for the items down the side, and one
link table that links them together.  The existance of a record in the
link table indicates a checked box, while no record in the link table
indicates an unchecked box.

Pull out your list of items across the top as a simple recordset. 
Pull out your list of items down the side, including a list of the
top-items that are checked for the side-item (using the link table). 
With MySQL, you'd use a subquery and the GROUP_CONCAT function; I
don't know about other DBs.

Loop over the top-items to render the top labels.  Then loop over the
side-items to render the table rows, and within each row, loop over
the top-items again to render the individual cells.  Use the list of
checked top-items that you computed as part of your query for the side
items to check the appropriate top-items in each row.  Name each
checkbox something like ch_#topItemId#_#sideItemId#, which will make
processing the form submission pretty simple (just loop over
form.fieldnames, and treat each field as a list to extract the two
IDs).

Hopefully that all makes sense.

cheers,
barneyb

On 6/14/05, Anthony Crawford <[EMAIL PROTECTED]> wrote:
> Hi all,
> I have a unique puzzle to solve that I have currently not come across before. 
> Based on the research that I have done so far, the task I have at hand is to 
> create a 'dynamic checkbox matrix'. I am not entirely sure how the database 
> should be structured to ensure efficient storage of the results. There is 
> also the concern of populating the table with the appropriate columns, rows, 
> and checkboxes dynamically. There will be more than one of these tables per 
> page according to a list of medical conditions. Matrix 1 could pertain to 
> Heart conditions, Matrix 2 could pertain to Blood conditions, etc.
> 
> The rows and column headings will mostly be fixed and not likely to change 
> but, there is the possibility. So I was thinking of either creating tables in 
> the database with the row and column titles, OR creating variable arrays in 
> CF for the rows and columns respectively.
> 
> There are a few issues I am not sure how to implement and therefore have come 
> to the experts @ HOF.
> 1. What is the best way to dynamically name each checkbox field, so that the 
> data can be saved efficiently?
> 2. What is the best way to design the database to hold the results of each 
> matrix?
> 3. How should I save/convert the form data from the matrix to the database?
> 
> One idea I had was to use a comma delimited list for saving/retrieving the 
> data in each row of checkboxes. Only problem is if there is another column 
> added, the data would not correspond to the right checkbox anymore.
> I hope I have been descriptive enough in offering this puzzle. Thanks for any 
> help received.
> 

-- 
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/

Got Gmail? I have 50 invites.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:209489
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to