473,386 Members | 1,654 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,386 software developers and data experts.

Array never changes

The user can choose either a region or a country on a form and submits the form to this page.
First, code gets a list of events for the country or for the region:

Expand|Select|Wrap|Line Numbers
  1.   . . . 
  2.    if (request.form("country_sel") < 0) then
  3.       allevents = getEventsByRegion(request.form("reg"),1)
  4.    else
  5.       allevents = getEvents(request.form("country_sel"),1)
  6.    end if
  7.    . . .
Later, the page should loop through all the events extracted for the country or region and at each loop get a list of particular information for the event:

Expand|Select|Wrap|Line Numbers
  1.  . . . 
  2.    <% for a=0 to ubound(allevents,2)
  3.     evid = allevents(0,a)
  4.     eventinfo = getEventInfo(evid,1)
  5.     if isarray(eventinfo) then
  6.         evtitle = eventinfo(1,0)
  7.    . . . 
But what is happening is the loop only ever gets the first event's info. For example, if I have

Event Id:<%=evid%> and Event Title:<%=evititle%>

what I get is

Event Id:1 Event Title:first event
Event Id:2 Event Title:first event
Event Id:3 Event Title:first event
. . .

It is like the code is preserving the array "eventinfo" in spite of the call to the function.
What gives? Explain please!
Nov 1 '07 #1
1 1059
markrawlingson
346 Expert 100+
Hi Dan,

Welcome to TSDN. Please use proper code tags when you are posting, makes it much easier to read!

It looks like you are only ever referencing record 0 within the eventinfo array.

For instance..

Expand|Select|Wrap|Line Numbers
  1. 'here you are using a function called getEventInfo() to set eventinfo up as what looks to be a multi-dimensional array
  2. eventinfo = getEventInfo(evid,1)
  3.  
  4. if isarray(eventinfo) then
  5.    'And here, you are setting the value of column 1, record 0. Which will always pull the information from that location since you are looping and always setting the same indice values.
  6.    evtitle = eventinfo(1,0)
  7. End If
  8.  
That is, unless your getEventInfo() function writes different information to the eventinfo array during each loop. If that is the case please show the code behind that function.

Sincerely,
Mark
Nov 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Ben Katz | last post by:
Is it possible to have a JavaScript object that works just like a standard Array, except that when the array is modified, a function gets called which can then do some processing on the array? ...
1
by: Ben Katz | last post by:
Is it possible to have an Array object (or an object derived from Array) that is 'aware' of other code modifying its contents? I'd like to have such an "onModify" function process an array...
4
by: JonathanG | last post by:
All, Thanks in advance for any help. I am attempting to write a property that is an array of strings. I am trying to trap the event when one of the strings in the array changes. When I step...
3
by: Eric Lilja | last post by:
Assignment: Create a 3x4 2-dimensional array of integers. Populate each element using some non-random scheme so that no two elemens contain the same value. Then create two functions for printing...
8
by: Piotrek | last post by:
Hi, Like almost all of beginners I have problem understanding pointers. Please, look at this piece of code, and please explain me why myswap function doesn't work as it's supposed to do, whereas...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.