Answered
Updating multiple select in form
I am trying to work out how to get my select drop down in my
update form to select the existing selected options and also to
display the non-selected items in a form to update the relevant
tables.
Here is an example of what I am trying to do.
Say I want to catalogue all my music CDs. I have a table for CD information (title, band, release date etc) called CDs a table for Categories (eg pop, rock, jazz, blues etc) and a Lookup table which stores the CD_ID and the Category_ID that were selected when entering the CD details. As each CD could fit multiple categories the select enables multiple selections for the appropriate categories. eg a CD could fit the Jazz, Progressive and Fusion categories.
So when the CD is added to the database the CD info goes into the CDs table and the CD_ID is then used to populate the Lookup table with the various Category_ID's from the Categories table. This is done with a looping insert statement so that the CD_ID is inserted multiple times for each Category_ID so a number of rows are added to the Lookup table depending on how many Categories were selected when the CD info was being added.
Now the question is: I want to build a form to be able to update the CD information. It needs to have a select drop down box that will display the existing selections and also the other selections from the Categories table so you can add new ones or change the existing selections.
I know this must be a common thing to do but I can't get my head around it. There must be a simple elegant way of doing this. I don't want any options duplicated in the drop down select list, just the existing seleted options and all the other options that weren't selected.
Hope this makes sense.
Would really appreciate some solution with this as I am sure it is a common scenario and I will need to know how to deal with it in the future. I can't seem to find any solutions for this example in the ColdFusion books I have read.
Thanks John

Here is an example of what I am trying to do.
Say I want to catalogue all my music CDs. I have a table for CD information (title, band, release date etc) called CDs a table for Categories (eg pop, rock, jazz, blues etc) and a Lookup table which stores the CD_ID and the Category_ID that were selected when entering the CD details. As each CD could fit multiple categories the select enables multiple selections for the appropriate categories. eg a CD could fit the Jazz, Progressive and Fusion categories.
So when the CD is added to the database the CD info goes into the CDs table and the CD_ID is then used to populate the Lookup table with the various Category_ID's from the Categories table. This is done with a looping insert statement so that the CD_ID is inserted multiple times for each Category_ID so a number of rows are added to the Lookup table depending on how many Categories were selected when the CD info was being added.
Now the question is: I want to build a form to be able to update the CD information. It needs to have a select drop down box that will display the existing selections and also the other selections from the Categories table so you can add new ones or change the existing selections.
I know this must be a common thing to do but I can't get my head around it. There must be a simple elegant way of doing this. I don't want any options duplicated in the drop down select list, just the existing seleted options and all the other options that weren't selected.
Hope this makes sense.
Would really appreciate some solution with this as I am sure it is a common scenario and I will need to know how to deal with it in the future. I can't seem to find any solutions for this example in the ColdFusion books I have read.
Thanks John
