|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Dynamic list generation
Ok I want to query my database and get a comma list of images and then out put them into an array dynamically. I have this non dynamic list nowEric Creese 06/10/04 10:10 A Well, I assume you used that fake code below as an example. There is noRaymond Camden 06/10/04 10:14 A You'd need a listQualify() in there too..Charlie Griefer 06/10/04 11:24 A Original Message:Scott Brady 06/10/04 12:53 P Original Message:Scott Brady 06/10/04 12:54 P > > Well, I assume you used that fake code below as an example.Raymond Camden 06/10/04 01:25 P Original Message:Scott Brady 06/10/04 01:02 P If you are sure the imagepath doesn't contain any characters that havePascal Peters 06/10/04 01:05 P yepEric Creese 06/10/04 01:35 P Original Message:Scott Brady 06/10/04 02:24 P Ok I want to query my database and get a comma list of images and then out put them into an array dynamically. I have this non dynamic list now <Script> var slideurl=new Array("images/1.gif","images/2.gif","images/3.gif") </script> I want to replace the script above with the dynamic output list using a query like this <cfquery name="getimglist" datasource="foo"> SELECT 'images/'+''+signimage FROM signs WHERE signtype =1; </cfquery> . Well, I assume you used that fake code below as an example. There is no simple way to auto-make an array in one line. You can however use a UDF: http://www.cflib.org/udf.cfm?ID=683 That being said - if you wanted to use the udf above, you can access a list from a query by using the valueList function: <cfset foo = array(valueList(queryname.columnname))> You'd need a listQualify() in there too.. var slideurl=new Array(<cfoutput>#listQualify(getimgList.valueList, "'")#</cfoutput>) (where the second argument of listQualify() is doublequote-singlequote-doublequote) > Well, I assume you used that fake code below as an example. There is no > simple way to auto-make an array in one line. You can however use a UDF: > > http://www.cflib.org/udf.cfm?ID=683 > > That being said - if you wanted to use the udf above, you can access a list ----- Excess quoted text cut - see Original Post for more ----- Original Message: ----- Excess quoted text cut - see Original Post for more ----- <cfset myList = ListToArray(ValueList(getimglist.myImg))> should do the trick. Note that you do need to alias that column in the query. Scott --------------------------- Scott Brady http://www.scottbrady.net/ Original Message: ----- Excess quoted text cut - see Original Post for more ----- *cough* ListToArray() *cough* I just think you're trying to push people to cflib :) Scott --------------------------- Scott Brady http://www.scottbrady.net/ ----- Excess quoted text cut - see Original Post for more ----- Nah - just don't pay any attention to all those Google ads. ;) Original Message: > From: "Eric Creese" Oh, never mind. I thought you wanted to create a new CF array. I think others got your answer for you. Scott --------------------------- Scott Brady http://www.scottbrady.net/ If you are sure the imagepath doesn't contain any characters that have to be escaped in JS (like '," or \) you could do <cfquery name="getimglist" datasource="foo"> SELECT 'images/'+''+signimage as img FROM signs WHERE signtype =1; </cfquery> .... <Script> var slideurl=new Array(#QuotedValueList(getimglist.img)#) </script> Otherwise: <script type="text/javascript"> var slideurl = new Array(#ListQualify(JSStringFormat(ValueList(getimglist.img)),"'"))#); </script> And if your values can contain commas: <script type="text/javascript"> var slideurl = new Array(#Replace(ListQualify(JSStringFormat(ValueList(getimglist.img,chr(7 ))),"'",chr(7)),chr(7),",","all")#); </script> ----- Excess quoted text cut - see Original Post for more ----- yep Original Message: > From: "Eric Creese" Oh, never mind. I thought you wanted to create a new CF array. I think others got your answer for you. Scott --------------------------- Scott Brady http://www.scottbrady.net/ _____ Original Message: > From: "Raymond Camden" > Nah - just don't pay any attention to all those Google ads. ;) Considering I misunderstood the question in this thread, paying attention to Google ads would seem to be the LEAST of my concerns. :) Scott --------------------------- Scott Brady http://www.scottbrady.net/
|
May 20, 2013
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||