|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
loading associative arrays
I am trying to load an associative array from a recordset. Anyone know how to do this?
![]() |
|
#2
|
||||
|
||||
|
__________________
_______________ Matt |
|
#3
|
|||
|
|||
|
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. |
|
#4
|
|||
|
|||
|
imbrokn wrote
Quote:
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 |
|
#5
|
|||
|
|||
|
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]); } |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > loading associative arrays |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|