numeric form field values and calculations ASP

  • Thread starter Thread starter Mettá
  • Start date Start date
M

Mettá

My brain has packed up!


Trying to use a hidden field values as say 4.85 but on the next page when I
try to use it I get just the whole number "4"

<input type="hidden" name="prce" value="4.85">
and an open field for quantity as "qty"


On the next page I have say...

<%Dim tprice
tprice=(Int(request.form("qty")))*(Int(request.form("prce")))

%>
<p>Price £<%=tprice%>
Trouble is I get £8 instead of 4.85x2 £ 9.70

Any suggestions!!

Thanks
M
 
Int(request.form("qty")) converts request.form("qty") to an integer. Integers
have no factional portion, so yup, 4.85 becomes 4.

Rather than Int, you shold probably use CCur (convert to currency) or CSng
(convert to single-precision floating point).

Jim Buyens
Microsoft MVP
http://www.interlacken.com
Author of:
o--> Microsoft Visual Web Developer 2005 Express Edition: Build a Web Site
Now!
o--> Microsoft Office FrontPage 2003 Inside Out
o--> Microsoft Windows SharePoint Services Inside Out
o--> Faster Smarter Beginning Programming
 
Back
Top