Skip to main content
April 12, 2010
Question

cfselect selected= not working properly

  • April 12, 2010
  • 1 reply
  • 2175 views

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!

    This topic has been closed for replies.

    1 reply

    Inspiring
    April 12, 2010

    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.

    April 12, 2010

    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.

    Inspiring
    April 13, 2010

    The next thing to check is that the value of query1 is included somewhere is query2.