0

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>
2
Contributors
5
Replies
6
Views
7 Years
Discussion Span
Last Post by arrgh
0

The most common cause is the value you're trying to select does not exist in the values used to populate your list.

For one thing, QUERY1 appears to be selecting all records from tblMain. So when you use selected="#QUERY1.TrussTypeID#" CF will use the value in the first record of the query only. So perhaps that's your problem.

Also, I'd suggest you cfdump both #QUERY1.TrussTypeID# and #query2#. Does #query2# actually contain the _value_ #QUERY1.TrussTypeID# ?

Edited by arrgh: n/a

0

My bad. Query1 is incomplete as I wrote it. I was trying to save space. There is a WHERE clause in it, it returns just one record, so that isn't the problem.


The most common cause is the value you're trying to select does not exist in the values used to populate your list.

For one thing, QUERY1 appears to be selecting all records from tblMain. So when you use selected="#QUERY1.TrussTypeID#" CF will use the value in the first record of the query only. So perhaps that's your problem.

Also, I'd suggest you cfdump both #QUERY1.TrussTypeID# and #query2#. Does #query2# actually contain the _value_ #QUERY1.TrussTypeID# ?

0

And what about the rest? The best way to figure out why the query isn't selecting anything is to cfdump the data it's using. It could be you're using a totally wrong value. But you won't know it unless you see the values

<cfdump var="#query1#">
<cfdump var="#query2#">

0

Very true... I didn't put all those details here, trying to keep it short. my bad. My queries are perfectly fine.

I ended up abandoning cfselect b/c I couldn't quite get that selected attribute to pan out.
Instead, I used 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>

And what about the rest? The best way to figure out why the query isn't selecting anything is to cfdump the data it's using. It could be you're using a totally wrong value. But you won't know it unless you see the values

<cfdump var="#query1#">
<cfdump var="#query2#">

0

No, I didn't mean you had to post the results. Just asking if you tried the basic troubleshooting techniques I mentioned. Since cfselect's definitely do work, it must have been something in your code. (I guess I'm just stubborn and curious. I wouldn't have been able rest until I found the problem in my code ;-) But glad you have something working now.

Edited by arrgh: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.