Posted on 2002-05-16
I am agravated that I have not yet come to grasp with the logic of looping(never sure of which one to use and when).
here is my situation.
have 2 tables
prodid (int) prodno (key) Pc_description(varchar 50)
1 2548 green eggs and ham
2 2549 Cats, socks the
this table populates a dropdown list using:
select pc_description from products
<select name="productcodes" size="3" multiple>
<option value="#PC_description#"><font face="Geneva, Arial, Helvetica, san-serif" size="1">#PC_description#</font></option>
some of the items in this list have commas in them and must be kept together.
now on insert several things happen.
I must now get the prodno for this PC_description so I do this.
<cfloop list="#form.productcodes#" Index="productcodes">
<!---convert the string to product numbers --->
<cfquery name="convert_pcdescription_to_productcode" datasource="vendors">
WHERE (dbo.PRODUCTS.Pc_Description = '#form.productcodes#') </cfquery>
Now that that has been resolved i need to insert this record selection into another table that holds record specific information depending on the vendornumber.
I do this by :
<!--- insert them individualy --->
<cfquery name="CT_Prod_Codes" datasource="vendors">
Insert into ExhProd(vendorNumber, Prodno)
values (#variable.vendornumber#, '#prodno#')
this works great if I only select 1 selection from my dropdown box.
how do I get it to
1. get it to break up the multiple selections from the selection box an list them individual records for insert as individual records.
2. get em to not break up the Pc_description at the commas.
thanks ih advance...