Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Array Question

Status
Not open for further replies.

egolds

MIS
Aug 29, 2001
105
US
Hi all, I'm looking for some help on an Array. My application has a number of pages with date drop downs. I am providing the user with Month, Day, Year Drop downs. For the Month Dropdowns I want to use a two dimentional array. At the page level this works fine:

dim arrMonth(11,2)
arrMonth(0,0)="01"
arrMonth(0,1)="January"
arrMonth(1,0)="02"
arrMonth(1,1)="February"
...

for i = 0 to ubound(arrMonth)
response.write(&quot;<option value =&quot;& arrMonth(i,0))
if arrMonth(i,0) = Session(&quot;MONTH&quot;) then response.write(&quot; selected&quot;)
if IsEmpty(Session(&quot;PastCoEndtMo2&quot;)) and i=12 then response.write(&quot; selected&quot;)
response.write(&quot;>&quot;&arrMonth(i,1)&&quot;</option>&quot;)

Since I have a number of pages with Month Drop downs I would like to use an Application Level variable (ideally initaited in the global.asa) to store the data. I know the basic syntax for Application variable Application(&quot;var&quot;)=&quot;Stuff&quot; or loading one dimentional arrays Application(&quot;arrMonth&quot;)=(&quot;01&quot;,&quot;02&quot;,&quot;03&quot;)... but are there any ways to do this with a two dimentional array?

Thanks in advance

 
Well,

Why can't you just do this:

Application(&quot;arrMonthNumbers&quot;)=(&quot;01&quot;,&quot;02&quot;,&quot;03&quot;)
Application(&quot;arrMonthNames&quot;)=(&quot;January&quot;,&quot;February&quot;,&quot;March&quot;)

I am pretty sure you can't store two-dimensional arrays in Application variable.

Hope this helps... <Dmitriy>
dbrom@crosswinds.net
 
Um...Not sure why you are using the arrays. What about this?

This is an example with only a single if stmt that is checking the current month, obviously you could check it against any other month or number

Dim ctr
Response.Write &quot;<select>&quot;
For ctr = 1 to 12
Response.Write &quot;<option value='&quot;&ctr&&quot;'&quot;
If month(date) = ctr Then response.Write &quot; selected&quot;
Response.Write &quot;>&quot;&monthName(ctr)&&quot;</option>&quot;
Next
Response.Write &quot;</select>&quot;

Wasn't sure if you were set on using double arrays or not, but if you weren't this will work as well.
 
The only reason I was using the arrays is the single digit months need to be 01, 02,... to enter into the database.

But now that I think about it I can convert them at the point they are entered into the datase.

Thanks for being a second pair of eyes.
 
Or just add the '0' as you build the drop down

Dim ctr, nmbr
Response.Write &quot;<select>&quot;
For ctr = 1 to 12
If ctr < 10 Then
nmbr = &quot;0&quot;&ctr
Else
nmbr = ctr
End If

Response.Write &quot;<option value='&quot;&nmbr&&quot;'&quot;
If month(date) = ctr Then response.Write &quot; selected&quot;
Response.Write &quot;>&quot;&monthName(ctr)&&quot;</option>&quot;
Next
Response.Write &quot;</select>&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top