ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old March 6th, 2003, 10:19 AM
stcoder stcoder is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: reno
Posts: 18 stcoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
loading associative arrays

I am trying to load an associative array from a recordset. Anyone know how to do this?

Reply With Quote
  #2  
Old March 6th, 2003, 04:43 PM
Utopia's Avatar
Utopia Utopia is offline
superficial
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: Peterborough, England
Posts: 188 Utopia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 36 m 8 sec
Reputation Power: 7
__________________
_______________
Matt

Reply With Quote
  #3  
Old March 7th, 2003, 01:09 AM
imbrokn imbrokn is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2001
Location: NJ
Posts: 428 imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level)imbrokn User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 11 h 34 m 8 sec
Reputation Power: 10
Send a message via AIM to imbrokn
ASP doesn't have associative arrays like PHP or Perl so it is kind of sucky like that. You'll have to add key/item pairs for each field/value you have in your recordset. you can easily do this with a loop:

set dict = server.createobject("scripting.dictionary")

' assuming you have a recordset already
for each fld in rs.fields
dict.add fld, rs(fld)
next

think that is right.

Reply With Quote
  #4  
Old March 8th, 2003, 08:57 AM
ngibsonau ngibsonau is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 138 ngibsonau User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
imbrokn wrote
Quote:
ASP doesn't have associative arrays like PHP or Perl


I'm happy to dispute this!

Come on guys think about what you say before you make broad generalized, wide reaching statements.

ASP does have associative arrays.

That is if you use Javascript as the ASP scripting language.

Code:
<script language="javascript" runat="server">
var x = new Array();
x["dog"] = "black";
x["cat"] = "ginger";
</script>


I think using server side Javascript is not advertised well enough.
Javascript is a far better language than VBscript in almost all respects.
__________________
--

ngibsonau

Reply With Quote
  #5  
Old March 10th, 2003, 03:50 PM
stcoder stcoder is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Location: reno
Posts: 18 stcoder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thank you!

It works now, thanks to all who responded:
//Model of Associative Array assigned by recordset

//Creating new Array

var routeid = 0;
var routedirection = "";

var routefinder= new Array()

<% Do Until rsMisc.EOF %>
routeid = '<%=rsMisc("FULL_NAME")%>';
routedirection = '<%=rsMisc("ROUTE_CARDINALITY_ID")%>';
routefinder[routeid]=[routedirection];
<% rsMisc.MoveNext
Loop %>

//Model of assignment to select

for(i=0;i<document.ArrayTest.routedir.options.length;i++)
{
document.ArrayTest.routedir.options[i] = null;
}

//Declare additional counter for boxes
var nxt = 0;

//Assigning Select Options from Array
for(var i in routefinder)
{
//Test Code //document.write(i);
document.ArrayTest.routedir.options[nxt++] = new Option(i, routefinder[i]);
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > loading associative 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 1 hosted by Hostway