cfselect, binding, and selectedvalues
ColdFusion's cfselect doesn't support the selectedvalue argument when using binding. I don't like the JavaScript solutions out there, so here's a simple SQL solution. If you have a cfselect like this one that makes a call to a remote CFC then the selectedvalue is completely ignored when the field is populated:7 Comments
Daniel Short wrote on 02/16/09 8:12 AM
There are a few problems with that query: 1. You can't do a subselect in a QofQ. 2. The (nolock) keywords aren't necessary (and will throw an error). 3. You can't use a case statement in a QofQ. So to get around those three issues you can use the following query:shekar wrote on 10/28/10 2:47 AM
Thanks a lot daniel..fixed a week's struggle..Matt G wrote on 04/15/11 7:26 AM
Great post...it gave me the idea of instead of messing with the sql when returning an array just move the value of the array to the top of the packAshraf wrote on 12/15/11 2:59 PM
Dan, Thanks for the article. It was easy to fix with your database solution instead of using JavaScript or other methods. Thanks again.Junaid wrote on 11/16/12 6:27 AM
I don't know a thing about CFC.. How would I be able to achieve this functionality? I'm trying this for 7 straight days without any luck.. Please help me out with this. :(Kim wrote on 05/02/13 10:05 AM
I just want to say THANK you for sharing this. I'm trying to set a default value but still allow the user to over-ride. Straight out binding doesn't allow this flexibility. Using the CASE used to direct the sort is so simple & totally solves my problem. Thanks again!!
LordRhumSifflar wrote on 02/16/09 5:39 AM
Well done. But, Do you know if (and how) we can do the same things with queryOfQuery? I've got an error executing database when i try to use this kind of query: