Returns list with value appended behind its last element.
See also ListPrepend, ListInsertAt, and ListSetAt.
ListAppend(list, value [, delimiters ])
Any list.
Number or list being appended.
Set of delimiters used in list.
When appending an element into a list, ColdFusion needs to insert a delimiter. If delimiters contains more than one delimiter, ColdFusion defaults to the first delimiter in the string, or, (comma) if delimiters was omitted.
If you intend to use list functions on strings that are delimited by the conjunction ", " (comma-space), as is common in HTTP header strings such as the COOKIE header, we recommend that you specify delimiters to include both comma and space because ColdFusion Server does not skip white space. For example,
ListAppend(List, "MyCookie", "," & CHR(32))
<!--- First, query to get some values for our list ---> <HTML> <HEAD> <TITLE>ListAppend Example</TITLE> </HEAD> <H3>ListAppend Example</H3> <!--- Find a list of users who wrote messages ---> <CFQUERY NAME="GetMessageUser" DATASOURCE="cfexpress"> SELECT Subject, Posted FROM Messages </CFQUERY> <CFSET temp = ValueList(GetMessageUser.Subject)> <!--- loop through the list and show it with ListGetAt ---> <H3>This is a list of <CFOUTPUT>#ListLen(temp)#</CFOUTPUT> subjects posted in messages.</H3> <CFLOOP FROM="1" TO="#ListLen(temp)#" INDEX="Counter"> <CFOUTPUT><LI>(#Counter#) SUBJECT: #ListGetAt(temp, Counter)#</ CFOUTPUT> </CFLOOP> <CFSET TempToo = ListAppend(temp, "More Applause for Express", ",")> <UL> <CFLOOP FROM="1" TO="#ListLen(temptoo)#" INDEX="Counter"> <CFOUTPUT><LI>(#Counter#) SUBJECT: #ListGetAt(temptoo, Counter)#</ CFOUTPUT> </CFLOOP> </UL> <P>Note that one new item "More Applause for Express" has been appended to the list, but has not been added to the database. </BODY> </HTML>