开发者

HTML text field not displaying decimal places of SQL money value

I have a text field who's value is populated from a SQL recordset (below).

<input name="txtAmount" id="txtAmount" type="text" size="10" maxlength="10" value="<%=RS("Amount")%>">

In the SQL table, the Amount field (which is a money data type) is inserted correctly, as 5.00 However, in the web page, it displays only as 5 (i.e. the decimal places are missing). Anyone know why this might be and how开发者_如何学编程 I can get the decimal places to display in the field? Thanks!


If you don't want the dollar sign, use

value="<%=FormatNumber(RS("Amount"),2)%>"


Applying formating will do the trick:

<input name="txtAmount" id="txtAmount" type="text" size="10" maxlength="10" 
       value="<%=FormatCurrency(RS("Amount"), 2)%>">


If your code is in .NET, you can use

<%= String.Format("{0:0.00}", RS("Amount")) %>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜