Skip to main content
Inspiring
June 11, 2006
Answered

Preserve cfselect value from detail page to edit page

I have on my edit page a cfselect that is populated by a query just like I have on my insert page wich is not the same one. Everything is working fine including updating, but the only thing that I can´t figure out is how to preserve the value of the option lets call it #value 3 of 5# in the detail page on the edit page. It comes up always as option #value 1 of 5#. Can you help me on this one?
Thanks,
Manuel
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer
June 11, 2006
<cfselect
name="ctype"
query="gtbiz"
value="btype"
selected="#gtcont.ctype#">
</cfselect>

2 tables... gtbiz query to table of biztypes... gtcont query of table of responses.

"gtcont.ctype" would be the "selected" value of from query "gtcont", while the "gtbiz" query would contain the select values that create dropdown list.

hope i got what you are asking this time

4 replies

Correct answer
June 11, 2006
<cfselect
name="ctype"
query="gtbiz"
value="btype"
selected="#gtcont.ctype#">
</cfselect>

2 tables... gtbiz query to table of biztypes... gtcont query of table of responses.

"gtcont.ctype" would be the "selected" value of from query "gtcont", while the "gtbiz" query would contain the select values that create dropdown list.

hope i got what you are asking this time
Translate
Inspiring
June 11, 2006
Thanks a million Ranger.
It's working beautifully. It was the selected property that I was missing.

Until next time,

Manuel
Translate
June 11, 2006
i think i understand...!?

on the edit page, you need to have a cfif statement on each value as in:

<select name="plstgrp">
<option value="0" <cfif plstgrp IS 0>selected</cfif>>None</option>
<option value="1" <cfif plstgrp IS 1>selected</cfif>>1</option>
<option value="2" <cfif plstgrp IS 2>selected</cfif>>2</option>
<option value="3" <cfif plstgrp IS 3>selected</cfif>>3</option>
<option value="4" <cfif plstgrp IS 4>selected</cfif>>4</option>
</select>

hope this does it...
Translate
Inspiring
June 11, 2006
I´ll try to explain better.
I have an insert page with a form that has a cfselect control wich values are populated by a query on a table that returns values 0,1,2,3,4,5. If the table is modified and now has values 0 to 10, then the cfselect control will display values 0, to 10. Let´s assume I create with the insert page a new record that contains value 3 on the cfselect control.
Now I search for this record and end up displaying it on a detail page. It displays correctly value 3 in the respective field. But then I need to edit the record. Clicking on the edit button (just as following the tutorial) I correctly end up on the edit page, that also has the correspondig cfselect control, also populated by the same query on the same table. But now, the value on the cfselect control, is not value 3, but value 0. I know that I'm missing some code here. Thanks Ranger.
Translate