Something like...
function myFields(idx)
{
this.Count = 0;
this.curfld = -1;
this.fld_arr = [];
this.fldname_idx_arr = [];
this.item = function(idx) {
return this.fld_arr[idx];
}
this.append = function(fldName, fldValue) {
if ( typeof(this.fldname_idx_arr[fldName]) == 'undefined' ) {
this.curfld = this.Count++;
this.fld_arr[this.curfld] = new myfield();
this.fldname_idx_arr[fldName.Count] = this.curfld;
}
else {
this.curfld = this.fldname_idx_arr[fldName]
}
this.fld_arr[this.curfld].name = fldName;
this.fld_arr[this.curfld].value = fldValue;
this.fld_arr[this.curfld].type = "string";
this.fld_arr[this.curfld].attributes = "";
return this.curfld;
}
return this.item(idx);
}
function myfield()
{
this.name = null;
this.value = null;
this.type = null;
this.attributes = null;
}
//var rs1 = new myrs(this);
var tstflds1 = new myFields();
var col1idx = tstflds1.append("col1", "this is a value for col1");
alert("col1idx = " + col1idx);
alert("0 name=[" + tstflds1.item(0).name + "] value=[" + tstflds1.item(0).valu + "]");
but where this also works...
alert("0 name=[" + tstflds1(0).name + "] value=[" + tstflds1(0).value + "]");
ie. javascript that impliments the ADO Fields collection
where item is the default property, from ADO Ref...
Item Property
Indicates a specific member of a collection, by name or ordinal number.
Syntax
Set object = collection.Item ( Index )
Return Value
Returns an object reference.
Parameters
Index
A Variant expression that evaluates either to the name or to the ordinal number of an object in a collection.
Remarks
Use the Item property to return a specific object in a collection. If Item cannot find an object in the collection corresponding to the Index argument, an error occurs. Also, some collections don't support named objects; for these collections, you must use ordinal number references.
The Item property is the default property for all collections; therefore, the following syntax forms are interchangeable:
[Edited by rshep2 on 18-Apr-12 02:53]
--
rshep2