House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Dynamic list generation

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Eric Creese
06/10/2004 10:10 AM

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> .

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
06/10/2004 10:14 AM

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))>

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Charlie Griefer
06/10/2004 11:24 AM

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 -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Scott Brady
06/10/2004 12:53 PM

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/

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Scott Brady
06/10/2004 12:54 PM

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/

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Raymond Camden
06/10/2004 01:25 PM

----- Excess quoted text cut - see Original Post for more ----- Nah - just don't pay any attention to all those Google ads. ;)

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Scott Brady
06/10/2004 01:02 PM

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/

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Pascal Peters
06/10/2004 01:05 PM

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 -----

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Eric Creese
06/10/2004 01:35 PM

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/   _____  

Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Scott Brady
06/10/2004 02:24 PM

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/


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 20, 2013

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31   

Designer, Developer and mobile workflow conference