• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Lesson 8. Working in Depth with Variables

Lesson 8. Working in Depth with Variables

As you have already learned, variables are one of the most important aspects of making Web content dynamic. So far, you have worked with simple variables, such as a variable to hold a person's first name, or the current date. But in ColdFusion, and most other programming languages, you have several complex variable types available to you. These variables hold more information and are organized differently.

List variables are actually simple variables like the ones you have used before. The only difference is that a list variable holds multiple values that are separated by a delimiter. A delimiter can be any character; most commonly, it's a comma. The delimiter must remain the same throughout the list of values. For example, a list variable for states, using the default comma delimiter, would look like this: IA,IN,MI,MN,NY. You worked with a list variable in Lesson 7 with the check box values.

Structures are very powerful ways to store related collections of information.

Arrays are a more complex type of variable. They are referenced by a single name, but can contain many different values. You might create an array to hold items in a shopping cart or to hold all of a user's information. Values in an array are assigned and referenced by position. So in an array of a user's information, the first position might be the user's name, the second position might be their street address, and so on. If you wanted to access the user's name, you would specify the first position in the array.

Structures are very similar to arrays in that one structure holds multiple values. The big difference is how they are referenced: rather than being referenced by position, structures use keys. Using the example above with a structure, you would reference the key names, which might be Name, Address, and so on.


In this lesson you will:

  • Learn about alternative variable types in ColdFusion

  • Use a list variable

  • Store items in an array

  • Access items in an array

  • Examine the use of structures

  • Learn how to pass a structure to another template


This lesson will take approximately 1 hour and 15 minutes to complete.


Starting Files:



Completed Files:





Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint