'Cold Fusion Output not displaying
I created a web page to compute Dollars and Cents. In our assignment we had a few values that we had to assign such as Pennies = 23; Nickels = 8; Dimes = 34 and Quarters =12. We need to enter the ColdFusion statements to display the resulting values in the second Column. Format the Total output as currency.
I created the table but when I run it in the URL it only shows up #Dollarformat(Pennies)#
What can I do to display the number.
<!---Add code to initial variables--->
<cfset Pennies = 23>
<cfset Nickels = 8>
<cfset Dimes = 34>
<cfset Quarters = 12>
<!---Add code to perform calculation--->
<cfset Total_In_Cents = Pennies*1+Nickels*5+Dimes*10+Quarters*25>
<cfset Total = Total_In_cents * 100>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Kitchen Sink Model 2123</title>
</head>
<body bgcolor="#FFFFFF">
<table align="center" width="200" border="center">
<tr>
<th allign"center" colspan="2">Coin Counter Results
</tr>
<tr>
<td align="right">Pennies:</td>
<td align="right"><cfoutput>#Dollarformat(Pennies)#</cfoutput></td>
</tr>
<td align="right">Nickels:</td>
<td align="right"><cfoutput>#Dollarformat(Nickels)#</cfoutput></td>
</tr>
<td align="right">Dimes:</td>
<td align="right"><cfoutput>#Dollarformat(Dimes)#</cfoutput></td>
</tr>
<td align="right">Quarters:</td>
<td align="right"><cfoutput>#Dollarformat(Quarters)#</cfoutput></td>
</tr>
<td align="right">Total(Cents):</td>
<td align="right"><cfoutput>#Dollarformat(Total_In_Cents)#</cfoutput></td>
</tr>
<td align="right">Total:</td>
<td align="right"><cfoutput>#Dollarformat(Total)#</cfoutput></td>
</tr>
</table>
Solution 1:[1]
Do a simple test to ensure your server is processing ColdFusion. Write a file called mytest.cfm with this code.
<cfset pennies = 23>
<cfoutput>#pennies#</cfoutput>
This will help your debugging to eliminate any complex code problems.
If you see "23" when you are running this, then your server is processing ColdFusion and something else is wrong, but like Leigh and Scott said in the comments I suspect your server is not processing ColdFusion, which would be confirmed if you see "#pennies#" or all of the code. If this is the case then you need to fix that (a separate question / problem) before answering your code, which looks like it would work, though Scott does point out some extra code help that improves the logic.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Cheyenne Throckmorton |