September 06, 2008
For ColdFusion hosting try HostMySite.com. |
Home /
Groups /
ColdFusion Talk (CF-Talk)
Dynamically prepolate the select box
I am dynamically buildin a select box . How can i prepopluate the data so when it loads it will select the previously submited answererik tom 05/09/08 01:18 P Hi Erik,Niski, Brian 05/09/08 01:32 P Another option is the iif() function ('inline if'). So:Dominic Watson 05/09/08 01:49 P Chapter 1:Bobby Hartsfield 05/09/08 02:01 P Literally.Brian Kotek 05/09/08 05:18 P I am really surprised nobody mentioned using a <cfselectPeterson, Chris 05/12/08 07:42 A Normally I'd agree, Chris. But since that is covered by the docs as well asBrian Kotek 05/12/08 09:36 A I thought it wasRichard Dillman 05/12/08 10:59 A >Another option is the iif() function ('inline if'). So:erik tom 05/09/08 02:50 P I am dynamically buildin a select box . How can i prepopluate the data so when it loads it will select the previously submited answer So far i got this <cfset selectOptions = selectOptions & '<option value="#options#_#id#"<cfif qryAnswers.answer eq #id#>selected</cfif>>#options#</option>'> Hi Erik, As I see it, there is more than one way to prepare your select box. At a quick glance you look headed in the right direction. Here is an alternative example of how I have done it... <SELECT id="aname" name="aname"> <OPTION VALUE="-1">Select Something</OPTION> <CFLOOP QUERY="ItemQ"> <CFIF PredeterminedValue EQ Item_ID> <OPTION VALUE="#Item_ID#" selected="selected"> #Item#</OPTION> <CFELSE> <OPTION VALUE="#Item_ID#">#Item#</OPTION> </CFIF> </CFLOOP> </SELECT> Brian I am dynamically buildin a select box . How can i prepopluate the data so when it loads it will select the previously submited answer So far i got this <cfset selectOptions = selectOptions & '<option value="#options#_#id#"<cfif qryAnswers.answer eq #id#>selected</cfif>>#options#</option>'> Another option is the iif() function ('inline if'). So: <cfloop query="ItemQ"> <option value="#Item_ID#" #iif(item_ID EQ selectedId, DE('selected="selected"'), DE(''))#> #Item# </option> </cfloop> Dominic -- Blog it up: http://fusion.dominicwatson.co.uk Chapter 1: <option value="#Item_ID#"<cfif item_ID EQ selectedId> selected="selected"</cfif>> .:.:.:.:.:.:.:.:.:.:.:.:. Bobby Hartsfield http://acoderslife.com http://cf4em.com Another option is the iif() function ('inline if'). So: <cfloop query="ItemQ"> <option value="#Item_ID#" #iif(item_ID EQ selectedId, DE('selected="selected"'), DE(''))#> #Item# </option> </cfloop> Dominic -- Blog it up: http://fusion.dominicwatson.co.uk Literally. http://www.amazon.com/Adobe-ColdFusion-Web-Application-Construction/dp/032151548X/ On Fri, May 9, 2008 at 2:00 PM, Bobby Hartsfield <bobby@acoderslife.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- I am really surprised nobody mentioned using a <cfselect selected="valueToBeSelected" query="queryName" value="columnName" /> Chris Peterson Literally. http://www.amazon.com/Adobe-ColdFusion-Web-Application-Construction/dp/0 32151548X/ On Fri, May 9, 2008 at 2:00 PM, Bobby Hartsfield <bobby@acoderslife.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- Normally I'd agree, Chris. But since that is covered by the docs as well as being something that would be explained completely in the first few chapters of any book on the subject, I assume most folks would think it was a given. Unfortunately, since Erik won't actually read the documentation or read a book on this, he'll have to keep asking questions that he could answer himself if he were to expend any effort at all in learning. The irony is, of course, that in the time he's wasted posing these questions to the list, he could already have read about all of this and have a full understanding of it! This truly is a case of "give a man a fish and feed him for a day, but teach a man to fish and feed him for a lifetime." Sigh. On Mon, May 12, 2008 at 7:39 AM, Peterson, Chris < cpeterson@gts.gaineycorp.com> wrote: > I am really surprised nobody mentioned using a <cfselect > selected="valueToBeSelected" query="queryName" value="columnName" /> > > Chris Peterson > > I thought it was "Give a man a fish and you have fed him for today. Teach a man to fish, and he will sit in the boat and drink beer all day." -- -- Richard Dillman rdillman@gmail.com "There are painters who transform the sun to a yellow spot, but there are others who with the help of their art and their intelligence, transform a yellow spot into the sun." - Pablo Picasso
|
Mailing Lists
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||