codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  asp: values in array not in order??  Archive Import (Sue Adams) at 13:01 on Saturday, August 16, 2003
 

I have a form on an asp page and am trying to write the code to place the values of all checkboxes that have been selected, into an array. The checkbox values will be used in a dynamic sql statement to retrieve information from an access database, to be displayed ont he page. Since I`ve never worked with arrays before I`ve been running tests and displaying values on the next page to help me figure out my code.

my array code reads like this:

CkBoxArray="("
for each objItem in request.Form()
if left(objItem,3)="ck_" and request.Form(objItem) <> "" then
CkBoxArray=CkBoxArray & request.Form(objItem) & ","
end if
next
theLen=len(CkBoxArray)
CkBoxArray=left(CkBoxArray,theLen-1)
CkBoxArray=CkBoxArray & ")"
response.Write("CkBoxArray = " & CkBoxArray & "<br>")

The problem is, the values that are sent to the array aren`t in any logical order. I ran three separate tests and below is the output:

Since I know the values of each of the checkboxes, I made my selections by value for each test; then clicked submit.......

Example 1:
Selected values in this order: 2800,2000,1400,1000
Array received: 1000,1400,2000, 2800

Example 2:
Selected values in this order: 1000, 1200, 2200, 2800
Array received: 1000,1200,2200,2800

Example 3:
Selected values in this order: 1000,2200,2400,2800
Array received: 1000,2400,2200,2800

As you can see, Example 1 and 2 places the selected values in numerical order (which is what I want, otherwise I`ll have to move to the beginning of the file/table at the beginning of the loop) But, for a reason unknown to me, in the 3rd example the values aren`t in order. Is there another way for me to create my array so that the values are received in order (form.element instead of objItem in request.Form) or would I be better off just moving to the beginning of the table at the beginning of the loop (moveFirst)? I`m trying to run this in an efficient manner, but am learning as I go and not sure whats best. I`d appreciate anyone that could explain/help with this. Thanks a million!


  Re: How to sort a VBSciprt Array  Troy Wolf at 10:43 on Tuesday, August 19, 2003
 

I`ve used the technique explained here:
http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=83
Troy Wolf: site expert
SnippetEdit Website Editor









CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  onChange issue
•  Remote program execution using cgi-perl
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me
•  pls help me with this..


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007