Forums
This topic is locked
Adding two fields together
Posted 12 Nov 2002 22:08:01
1
has voted
12 Nov 2002 22:08:01 Robert Kruse posted:
This should be pretty basic, but it's giving me a lot of trouble. I'm trying to add the values of Recordset1.Price1 and Recordset1.AdditionalCost in ASP JScript. Instead of adding the two values together, it put the two side by side. Here's the code I'm using....<% var MyTotal = ((Recordset1.Fields.Item("Price1") + (Recordset1.Fields.Item("AdditionalCost")); %>
If Price is 2 and AdditionalCosts is 2, the result is 22, rather than 4.
Please help.
Thanks
Replies
Replied 12 Nov 2002 22:17:53
12 Nov 2002 22:17:53 Brent Colflesh replied:
Dear Contact,
Are they declared numeric fields in your db?
Regards,
Brent
Are they declared numeric fields in your db?
Regards,
Brent
Replied 12 Nov 2002 22:38:09
12 Nov 2002 22:38:09 Robert Kruse replied:
Currency in MS Access
Replied 12 Nov 2002 22:40:42
12 Nov 2002 22:40:42 Robert Kruse replied:
If you swap out the + sign, with a - sign, * sign, / sign... it works perfect. It just won't add. This is very fustrating.
Replied 13 Nov 2002 00:45:39
13 Nov 2002 00:45:39 aron a replied:
Just try...
<% var MyTotal = 0 + ((Recordset1.Fields.Item("Price1") + (Recordset1.Fields.Item("AdditionalCost")); %>
Think it will work
<% var MyTotal = 0 + ((Recordset1.Fields.Item("Price1") + (Recordset1.Fields.Item("AdditionalCost")); %>
Think it will work
Replied 13 Nov 2002 02:38:23
13 Nov 2002 02:38:23 Robert Kruse replied:
Adding the "0 +", didn't seem to do anything. Thanks though.
Replied 13 Nov 2002 17:25:29
13 Nov 2002 17:25:29 Brent Colflesh replied:
Dear Contact,
Instead of the + symbol, try:
&&
or
|| (double-pipes, above the backslash)
Regards,
Brent
Instead of the + symbol, try:
&&
or
|| (double-pipes, above the backslash)
Regards,
Brent
Replied 14 Nov 2002 13:38:28
14 Nov 2002 13:38:28 Stewart Bond replied:
I have cosntructed similar code and mine work, try below:
<%
Dim MyTotal
MyTotal = 0
MyTotal = ((Recordset1.Fields.Item("Price1".Value)+(Recordset1.Fields.Item("AdditionalCost".Value))
It should give you 4 rather than 22
I hope this works for you.
Stewart
<%
Dim MyTotal
MyTotal = 0
MyTotal = ((Recordset1.Fields.Item("Price1".Value)+(Recordset1.Fields.Item("AdditionalCost".Value))
It should give you 4 rather than 22
I hope this works for you.
Stewart
Replied 14 Nov 2002 13:40:38
14 Nov 2002 13:40:38 Stewart Bond replied:
SORRY, last reply is wrong.
code should be:
<%
Dim MyTotal
MyTotal = ((Recordset1.Fields.Item("Price1".Value)+(Recordset1.Fields.Item("AdditionalCost".Value))
%>
Stewart
code should be:
<%
Dim MyTotal
MyTotal = ((Recordset1.Fields.Item("Price1".Value)+(Recordset1.Fields.Item("AdditionalCost".Value))
%>
Stewart
Replied 14 Nov 2002 15:10:34
14 Nov 2002 15:10:34 Dave Blohm replied:
Try this...add .value :
<% var MyTotal = ((Recordset1.Fields.Item("Price1".value) + (Recordset1.Fields.Item("AdditionalCost".value)); %>
Doc
Rangewalk Digital Studios
<% var MyTotal = ((Recordset1.Fields.Item("Price1".value) + (Recordset1.Fields.Item("AdditionalCost".value)); %>
Doc
Rangewalk Digital Studios