I have three db's 1)rep 2)Plant 3)RepPlant. A rep can cover mulitple plants,
hence the select multiple. I am haveing trouble displaying their plants in the
"Change" form. Once I can get that to work my goal is to delete existing
records From the RepPlant and replace with what ever has changed. Abreviated
code below. I know its messed up, but I cannot seem to get it to work.
<tr valign="baseline">
<td align="left" nowrap><a href="Add_plant.cfm">Plant</a>:</td>
<td align="left" nowrap> <select name="plantid" size="10" multiple
tabindex="7">
<cfoutput query="rsplant">
<option value="#rsplant.plantID#"> <cfif
(isDefined("rsPlant.plantid"))><cfloop query="rsRepPlant"></cfloop>
selected></cfif></option>
</cfoutput> </select></td>
</tr>
mxstu - 30 Sep 2005 20:25 GMT
1) Add a cfquery called "rsRepPlant" that retrieves all of the "plantID's" for
the selected "repID".
SELECT plantID FROM RepPlant WHERE repID = #selectedRepID#
2) Use the valueList() function to convert the query results to a
comma-delimited list of numbers
3) Use the listFind() function while outputing the select list items to
determine which "plantID's" should be preselected
<!--- convert "rsRepPlant" query results to list ---->
<cfset repPlantList = valueList(rsRepPlant.plantID)>
<form ....>
......
<select name="plantid" size="10" multiple tabindex="7">
<cfoutput query="rsPlant">
<option value="#plantID#" <cfif listFind(repPlantList, plantID) gt
0>selected</cfif>>#plantName#</option>
</cfoutput>
</select>
......
</form>