March 6th, 2003, 11:19 AM
loading associative arrays
I am trying to load an associative array from a recordset. Anyone know how to do this?
March 6th, 2003, 05:43 PM
March 7th, 2003, 02:09 AM
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)
think that is right.
March 8th, 2003, 09:57 AM
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.
var x = new Array();
x["dog"] = "black";
x["cat"] = "ginger";
March 10th, 2003, 04:50 PM
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")%>';
//Model of assignment to select
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]);