Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,250 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,204 people online right now. Registration is fast and FREE... Join Now!




ColdFusion Arrays

 
Reply to this topicStart new topic

ColdFusion Arrays, ColdFusion Arrays

blanket
14 Oct, 2008 - 08:10 AM
Post #1

New D.I.C Head
*

Joined: 14 Oct, 2008
Posts: 6

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 Oct, 2008 - 08:10 AM
User is offlineProfile CardPM
+Quote Post

sansclue
RE: ColdFusion Arrays
14 Oct, 2008 - 09:12 AM
Post #2

D.I.C Head
**

Joined: 21 Nov, 2007
Posts: 113



Thanked: 7 times
My Contributions
QUOTE(blanket @ 14 Oct, 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]#"


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.adobe.com/coldfusion/7/htmldocs/00000455.htm
User is offlineProfile CardPM
+Quote Post

blanket
RE: ColdFusion Arrays
14 Oct, 2008 - 09:38 AM
Post #3

New D.I.C Head
*

Joined: 14 Oct, 2008
Posts: 6

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

I also changed the dollor to dollar. Same results.
User is offlineProfile CardPM
+Quote Post

sansclue
RE: ColdFusion Arrays
14 Oct, 2008 - 09:46 AM
Post #4

D.I.C Head
**

Joined: 21 Nov, 2007
Posts: 113



Thanked: 7 times
My Contributions
QUOTE(blanket @ 14 Oct, 2008 - 10:38 AM) *

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 Oct, 2008 - 09:47 AM
User is offlineProfile CardPM
+Quote Post

blanket
RE: ColdFusion Arrays
14 Oct, 2008 - 10:44 AM
Post #5

New D.I.C Head
*

Joined: 14 Oct, 2008
Posts: 6

QUOTE(sansclue @ 14 Oct, 2008 - 10:46 AM) *

QUOTE(blanket @ 14 Oct, 2008 - 10:38 AM) *

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.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 04:09AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month