-1
我創建了一個網頁來計算美元和美分。在我們的任務中,我們有一些我們必須分配的值,例如Pennies = 23;鎳= 8;角錢= 34和季度= 12。我們需要輸入ColdFusion語句以在第二列中顯示結果值。將總產出格式化爲貨幣。Cold Fusion輸出不顯示
我創建表,但是當我在URL上運行它,它只會顯示#Dollarformat(便士)#
我能做些什麼來顯示數字。
<!---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>
它沒有任何問題。在[trycfm.com](http://trycf.com/gist/ef0c8f3910180cc376a8/acf2016?theme=monokai)上測試時,請注意它運行完美嗎?如果您看到cfml代碼,即'#Dollarformat(Pennies)#',這意味着它不會被CF服務器正確評估。要麼你沒有正確加載'.cfm'腳本,或者你的CF服務器配置錯誤。您是否已成功運行任何* .cfm腳本? – Leigh
也許我沒有正確加載它。在URL中傳遞值只是.cfm?pennies = 4 – Eric1294
您是否看到所有的ColdFusion代碼或者您正在嘗試輸出的內容?如果它是前者,這聽起來像你沒有正確配置你的Web服務器。另外,你的邏輯是有缺陷的。由於您已經獲得了前一行中的總美分數,所以不需要''。也沒有必要使用'pennies * 1',只需使用'pennies' –