I have an ASP page that is creating an array of objects that need to be
passed to another ASP page. I know that one way to pass this information
is to join everything in the array into a string and place the string in a
hidden variable. Now I'm trying to create a function that will combine
everything in the array into a string. Here's my problem:
I want to make the string look like this:
Obj1Prop1|Obj1Prop2|ObjProp3||Obj2Prop1|Obj2Prop2|Obj2Prop3||Obj3Prop1|...
in which each object is separated by double bars and each property within
the object is separated by a single bar. When I get to the second page, I
would simply split on the double bar to get an array of objects. Then
split each array element on the single bar to get the separate properties
for the specific object.
The problem I'm having is with my "for each" loop. I believe I need 2
loops, one inside the other, to do this. Here is what I have so far:
Function JoinObjArray(sArrayName, Delimiter) {
for (obj in sArrayName) {
for (prop in obj) {
sString = sString + sArray[obj].prop + Delimiter;
}
sString = sString + Delimiter;
}
}
Is this function OK the way it's written, and if not, what should be
changed? I'm not worried about whether it works or not, just if I have
the correct syntax. Once I have the syntax is right, I'll work on
debugging it.
Chris