p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 13th, 2003, 12:15 AM
Friend of Wrox
Points: 708, Level: 10
Points: 708, Level: 10 Points: 708, Level: 10 Points: 708, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Oklahoma City, Oklahoma, USA.
Posts: 243
Thanks: 0
Thanked 0 Times in 0 Posts
Default Determine if something has already been selected

Can somebody suggest a more effiecient way to do this. I have a list of items and you can add these items to what is basically a simple shopping cart. What I am wanting to do is when you return to the list I want to be able to determine what has been selected.

Right now this runs kind of slow when you have about 20 items per page. What I am doing is I have two select statements one for the Items and one for the cart. From there I am doing the following

While Not objItem.EOF

Response.Write objItem("ItemName")

While Not objList.EOF
 If objItem("ItemID") = objList("ItemID_List") Then
    Response.Write "Selected"
 End If
objList.MoveNext
Wend

objItem.MoveNext
Wend

It seems there would be a better way I have tried JOINS on the select statement but cannot get those to work correctly, if that would be faster I will go back to trying to get those to work.

All help is greatly appreciated.
Thanks
__________________
Peace
Mike
http://www.eclecticpixel.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old June 13th, 2003, 02:02 AM
Friend of Wrox
Points: 222, Level: 4
Points: 222, Level: 4 Points: 222, Level: 4 Points: 222, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Sydney, NSW, Australia.
Posts: 111
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm not really sure what/how you're showing your selected items. That said, instead of an inner loop for each item in the outer loop, you can do this more efficiently, with only a single loop through each collection by:
a) ordering each collection the same way (eg by ItemID ascending).
b) As you go through each item in the outer loop, you check to see if the current item in the inner loop the same value (in which case write "selected"), or a lower value (shouldn't occur), and in which case advance the inner loop by one step.

So, suppose you have items 1,2,3,4,5,6,7,8 and the user has items 2 and 4 in their basket. Outer array (1,2,3,4,5), Inner Array (2,4)
For the first iteration, the value of the outer array is 1, and the inner array is 2, so you just write out "1"
For the second iteration, the value of the outer array is 2, and the value of the inner array is 2, so you write out "2 selected", -and- advance the inner array to the next element.
For the third iteration, the value of the outer array is 3, and the value of the inner array is 4, so you just write "3"
For the fourth iteration, the value of the outer array is 4, and the value of the inner array is 4, so you write "4 selected", -and- advance the counter for the inner array.
For -all- subsequent iterations (5,6,7,8), you know you have already gone past the last value in the inner array, so you just write them out without having to do any checking.

Cheers
Ken



www.adOpenStatic.com
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Determine if numeric Scootterp Access VBA 4 March 2nd, 2006 08:44 AM
Determine Credentials bmumph C# 2 November 1st, 2005 12:18 PM
syntax error on <option selected="selected"> hamid HTML Code Clinic 1 October 13th, 2004 10:20 AM
Determine OS adman Beginning VB 6 2 January 5th, 2004 02:26 AM
Need Help: Can't determine cause of error xgbnow Visual C++ 3 September 22nd, 2003 06:00 PM



All times are GMT -4. The time now is 04:17 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc