 |
| Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0 |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

January 19th, 2004, 12:05 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Shopping Cart query
Hi all
I'm building this shopping cart but want a sliding scale of postage and packing depending on how much is spent in the shop. I'm using this but it's throwing up errors. Here is the basis of my code (intTotalPrice is the total Price and intPP is postage and packing).
if intTotalPrice > 10 then intPP = 2.50
else
if intTotalPrice > 30 then intPP = 5.00
end if
end if
I'm sure the codes totally wrong but was wondering if anyone could help me go about it the correct way.
thanks
Adam
|
|

January 19th, 2004, 12:39 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If the first condition tests true the second condition will never test...try reversing the logic
I
<%
If intTotalPrice>30 then
intPP=5.00
else
if intTotalPrice>10 intPP=2.5
end if
end if
One last thing, do you want a value if intTotalPrice is < 10?
Let me know if this helps
John
|
|

January 19th, 2004, 01:22 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi John,
Yes that would be a good idea to have a < 10 option too.
Would that mean using an else if statement?
thanks
Adam
|
|

January 19th, 2004, 01:26 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Adam,
You can either use another else or perhaps a case statement...if you think the increments will increase you may be better off using a case statement now. However, if you think the logic criteria will just remain at three levels another else will work fine.
<%
If intTotalPrice>30 then
intPP=5.00
else
if intTotalPrice>10 intPP=2.5
else
intPP=someotheramount
end if
end if
%>
|
|

January 19th, 2004, 01:49 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi John
This is what I've put in the code
If intTotalPrice > 30 then
intPP = 5.00
else
if intTotalPrice > 10 intPP = 2.5 then
else
intPP=1.5
end if
end if
but I get the following error:
Microsoft VBScript compilation error '800a03ea'
Syntax error
checkout1.asp, line 223
else if
-------^
this is on line 223
else if
thanks
Adam
|
|

January 19th, 2004, 02:01 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Does that line read "else" or "else if"
John
|
|

January 19th, 2004, 02:09 PM
|
|
Authorized User
|
|
Join Date: Dec 2003
Posts: 81
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Sorry,,,,my mistake here is the correct code
<%
If intTotalPrice>30 then
intPP=5.00
else
if intTotalPrice>10 then
intPP=2.5
else
intPP=someotheramount
end if
end if
%>
|
|

January 19th, 2004, 02:23 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Great, thanks alot John
Works fine!
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Shopping Cart Query |
rsm42 |
ASP.NET 1.0 and 1.1 Basics |
4 |
April 10th, 2007 01:32 PM |
| Shopping Cart |
seannie |
ASP.NET 2.0 Basics |
0 |
December 12th, 2006 10:28 AM |
| Shopping cart help |
rsm42 |
ASP.NET 1.0 and 1.1 Basics |
3 |
December 9th, 2006 06:09 AM |
| Shopping Cart |
inkrajesh |
ASP.NET 1.0 and 1.1 Basics |
2 |
February 28th, 2006 03:08 AM |
| shopping cart |
xipnl |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 |
1 |
June 10th, 2005 07:00 PM |
|
 |