Specifying decimal places on a variable in a string

Tag: asp-classic , decimal-point Author: lanyise Date: 2012-04-09

after briefly looking for a few hours I see multiple solutions to my problem but I am struggling to implement them and hopefully someone can help a noob.

The issue is that I have a drop down box in an ASP/MySQL web application that displays a few prices incorrectly. e.g if the data is 32.00 the figure displayed will be returned as 32, similarly if it 6.50 it displays as 6.5 The data type or the price is set to Decimal(19,2) length in the db table, and the price shows correctly elsewhere except in this one instance of options displayed in a drop down box. I am pretty certain there is an easy fix and would really appreciate a fix. I thought I could add .toFixed(2) , so in effect it was like this <%=DealCartsDB("price").toFixed(2)%>, but it say's not supported.

<select name="deal" class="qty" onChange="swapDeal()">
<option value="-1">CHOOSE YOUR DEAL</option>
<% while not DealCartsDB.Eof %>
<option value="<%=DealCartsDB("dealid")%>"<% if clng(dealID)=DealCartsDB("dealid") then %> selected<% end if %>><%=DealCartsDB("dealname")%>........&pound;<%=DealCartsDB("price")%></option>
<% DealCartsDB.MoveNextWend %></select>

Any help much appreciated, thank you.

Other Answer1

Try this:

<%= FormatNumber(DealCartsDB("price"), 2) %>


Brilliant. Thank you very much, worked like a charm.
Do feel free to accept the answer then...