473,411 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

asp: values in array not in order??

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!

-----------------------------
This message is posted by http://Asp.ForumsZone.com

Jul 19 '05 #1
1 2833
Sue.

1. Let all the Check Boxes have the same name with different Values. Example:

<INPUT TYPE=CHECKBOX NAME="DATA" VALUE="1000">1000<BR>
<INPUT TYPE=CHECKBOX NAME="DATA" VALUE="1200">1200<BR>
<INPUT TYPE=CHECKBOX NAME="DATA" VALUE="2200">2200<BR>
<INPUT TYPE=CHECKBOX NAME="DATA" VALUE="2800">2800<BR>

2. On the receiving page, place the follow function in your asp code. Example

<SCRIPT language="javascript" runat="server">
function sortData(strData){
var data_array = strData.split(",");
data_array.sort();
return data_array.join();
}
</SCRIPT>

<%
'Here you are using VBScript inside the ASP Deliminators.
strSelectedItems = Trim(Request("DATA"))
If Len(strSelectedItems ) > 0 Then
strSelectedItems = sortData(strSelectedItems)
'Do What Ever
End If
%>
HTH
-------------------------------------------------
d l b j r

Unambit from meager knowledge of inane others,
engender uncharted sagacity.
-------------------------------------------------
Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
7
by: Bruno Alexandre | last post by:
Hi guys, Sorry about the off topic, but I can't find the ASP group just the ASP dot NET If I want to block a user to change a form after submiting, I add a function that will disable the...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
4
Frinavale
by: Frinavale | last post by:
Introduction Sometimes, when developing web applications, we need to be able to dynamically load controls based on user selections. The following article describes a simple scenario where TextBox...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.