ColdFusion Arrays

ColdFusion Arrays

Page 1 of 1

4 Replies - 1419 Views - Last Post: 14 October 2008 - 11:44 AM Rate Topic: -----

#1 blanket  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 14-October 08

ColdFusion Arrays

Post icon  Posted 14 October 2008 - 09:10 AM

This is supposed to display in a table what am I doing wrong? When I test it in my browser it just displays the following:

"Product Price" "#products[i]#"
"#dollorformat(prices[i])#"
"#prices[11]#"


<html>
<head>
<title>Array Assignment</title>
</head>
<body>
<cfset products = ArrayNew(1)>
<cfset ArrayAppend(products,"Eggs")>
<cfset ArrayAppend(products,"Cheese")>
<cfset ArrayAppend(products,"Milk")>
<cfset ArrayAppend(products,"Bread")>
<cfset ArrayAppend(products,"Bananas")>
<cfset ArrayAppend(products,"Crackers")>
<cfset ArrayAppend(products,"Cereal")>
<cfset ArrayAppend(products,"Strawbaries")>
<cfset ArrayAppend(products,"Yogurt")>
<cfset ArrayAppend(products,"Chocolate Cake")>
<cfset prices = ArrayNew(1)>
<cfset ArrayAppend(prices,"$3.29")>
<cfset ArrayAppend(prices,"$4.50")>
<cfset ArrayAppend(prices,"$2.59")>
<cfset ArrayAppend(prices,"$1.95")>
<cfset ArrayAppend(prices,"$1.09")>
<cfset ArrayAppend(prices,"$1.20")>
<cfset ArrayAppend(prices,"$3.95")>
<cfset ArrayAppend(prices,"$1.89")>
<cfset ArrayAppend(prices,"$2.29")>
<cfset ArrayAppend(prices,"$3.79")>
<cfset ArrayAppend(prices,"The total cost is $26.54")>
<cfoutput>"Product Price"</cfoutput>
<table>
<cfloop from="1" to="#ArrayLen(products)#" index="i">
<tr>
<td>
<cfoutput>"#products[i]#"</cfoutput></td>
<td>
<cfoutput>"#dollorformat(prices[i])#"</cfoutput></td>
</tr>
</cfloop>
</table>
<cfoutput>"#prices[11]#"</cfoutput>
</body>
</html>

This post has been edited by blanket: 14 October 2008 - 09:10 AM


Is This A Good Question/Topic? 0
  • +

Replies To: ColdFusion Arrays

#2 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: ColdFusion Arrays

Posted 14 October 2008 - 10:12 AM

View Postblanket, on 14 Oct, 2008 - 09:10 AM, said:

This is supposed to display in a table what am I doing wrong? When I test it in my browser it just displays the following:

"Product Price" "#products[i]#"
"#dollorformat(prices[i])#"
"#prices[11]#"


The only way I can see that happening is if your webserver is not configured properly to execute coldFusion code. What do you see if you create a separate page and run this simple code?

<cfoutput>#now()#</cfoutput>


Quote

"#dollorformat(prices[i])#"


That said, the function name is mispelled. It is dollarformat
http://livedocs.adob...cs/00000455.htm
Was This Post Helpful? 0
  • +
  • -

#3 blanket  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 14-October 08

Re: ColdFusion Arrays

Posted 14 October 2008 - 10:38 AM

When I run that code I get #now()# in the browser.

I also changed the dollor to dollar. Same results.
Was This Post Helpful? 0
  • +
  • -

#4 sansclue  Icon User is offline

  • D.I.C Regular

Reputation: 29
  • View blog
  • Posts: 316
  • Joined: 21-November 07

Re: ColdFusion Arrays

Posted 14 October 2008 - 10:46 AM

View Postblanket, on 14 Oct, 2008 - 10:38 AM, said:

When I run that code I get #now()# in the browser.

I also changed the dollor to dollar. Same results.


It is displaying the CF code instead of executing it. That usually means your webserver is not properly configured.

I don't know much about webservers, but I do know it must be configured it so it knows to execute CF code, not just display it. If you're using the built-in webserver that comes with ColdFusion you might just try uninstalling and reinstalling.

This post has been edited by sansclue: 14 October 2008 - 10:47 AM

Was This Post Helpful? 0
  • +
  • -

#5 blanket  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 14-October 08

Re: ColdFusion Arrays

Posted 14 October 2008 - 11:44 AM

View Postsansclue, on 14 Oct, 2008 - 10:46 AM, said:

View Postblanket, on 14 Oct, 2008 - 10:38 AM, said:

When I run that code I get #now()# in the browser.

I also changed the dollor to dollar. Same results.


It is displaying the CF code instead of executing it. That usually means your webserver is not properly configured.

I don't know much about webservers, but I do know it must be configured it so it knows to execute CF code, not just display it. If you're using the built-in webserver that comes with ColdFusion you might just try uninstalling and reinstalling.


Thanks--I'll give it a try.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1