ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 11th, 2003, 11:27 AM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
Comparing Two Arrays

How do you compare the content of two arrays

I have one array - aLinkCat (contents: LinkID and CategoryID) and another array called aCat (contents: CategoryID)

I want to determine when the value in aLinkCat (CategoryID) matches the value in aCat (CatagoryID, CategoryName), so that I can indicate that categoryid has been selected.

I need to compare the second element in the first array with the first element in the second array.

Thanks in advance!

Last edited by aspnewbie : February 11th, 2003 at 12:00 PM.

Reply With Quote
  #2  
Old February 11th, 2003, 03:38 PM
aspnewbie aspnewbie is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: The Great White North
Posts: 361 aspnewbie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 58 m 50 sec
Reputation Power: 7
Send a message via MSN to aspnewbie
I got it to work eventually, although it's not pretty.

Code:

set oRS = GetRS(sConn, "usp_GetLinkCategories @lid =" & iLID)
sCategorySelect = ""
while not (oRS.eof or oRS.bof)
  sCategorySelect = sCategorySelect+ cstr(oRS("CategoryID")) + ","
  oRS.movenext
wend

if "" & sCategorySelect <>"" then 
  sCategorySelect = left(sCategorySelect,len(sCategorySelect)-1)
End if
'Response.Write sCategorySelect
		
y= split(sCategorySelect,",")
  aCat = GetArrRS(sConn,"usp_ListCategories")
sCategorySelect = "<Select name=""sCategorySelect"" multiple>"

If IsArray(aCat) then
  for j = 0 to Ubound(aCat, 2)
   sCategorySelect = sCategorySelect & "<option value="""  & aCat(0, j)  & """"
     for i = 0 to Ubound(y)
        if cint(y(i))=aCat(0, j) then
                 sCategorySelect = sCategorySelect + " selected "
	 exit for
        End if
     Next
sCategorySelect = sCategorySelect + ">" + aCat(1, j) 
sCategorySelect = sCategorySelect & "</option>"	
		
Next
End if				
sCategorySelect= sCategorySelect & "</select>"  


Presumably there is a shorter way. If anybody has any better suggestions, I'm all ears!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingASP Development > Comparing Two Arrays


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT