Copy link to clipboard
Copied
I have an update page with a cfselect populated from a query. I need the selected value to be = to a value from a different query.
I can only seem to get the first item in the cfselect to display when the page loads, making me think something is wrong w/my cfselect.
This tag, btw, is w/in a <cfoutput> tag from the other query.
ex:
<cfquery name="QUERY1">
SELECT tblMain.Name as name, tblMain.Other_Name, tblMain.TrussTypeID
FROM tblMain
</cfquery>
<!-- get list of all truss types -->
<cfquery2 name="QUERY2>
SELECT lkuTruss.TrussTypeID, lkuTruss.TrussType
FROM lkuTruss
ORDER BY lkuTruss.TrussType
</cfquery>
<cfoutput query="QUERY1">
<table>.....etc.
<td>
<!--populate select box w/all possible truss types. Have matching truss type for selected record pre-displayed-->
<cfselect name="i_p_select" query="QUERY2" value="TrussTypeID" display="TrussType" selected="#QUERY1.TrussTypeID#" />
etc etc...
</table>
</cfoutput>
I've seen other examples similar but mine won't work!
Copy link to clipboard
Copied
Either put a where clause into query1 so it only returns one row or specify a row number in the selected attribute of your cfselect.
Copy link to clipboard
Copied
There is a WHERE clause in query1. I didn't include it here simply to shorten the code.
That query is returning only one record.
Copy link to clipboard
Copied
The next thing to check is that the value of query1 is included somewhere is query2.
Copy link to clipboard
Copied
I decided the cfselect was acting too odd. I managed to get it done using some conditionals and a regular <select>
<CFOUTPUT QUERY="query1"><CFSET xx=#TrussTypeID#></CFOUTPUT>
<select name="i_p_select"><CFOUTPUT QUERY="query2"><option value="#TrussTypeID#"<CFIF #xx# IS #TrussTypeID#>Selected</CFIF>>#TrussType#</option></CFOUTPUT></SELECT>