/    Sign up×
Community /Pin to ProfileBookmark

Join all arrays

Hi I have a page containing three arrays. I would like to create a fourth array, containing the contents of the other three – which will then be sorted.

This part i can do. The trouble is, the original three arrays are named dynamically, so i cannot reference them directly in my code. The saving grace is they all start with the same name. Each one then has a number dynamically appended to it.

Therefore i guess my question is this. Is it possible to loop through every array on a page? If it were a form i was dealing with, not an array, i would do something like this.

[code=html]pageForms = document.form.length

for (x=0; x<pageForms x++) {
do somthing
}[/code]

I would have thought i could use pageArrays = document.Arrays.length, but this doesn’t seem to work.

Does anyone have any other ideas?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@spiderman11Oct 01.2008 — I think you can't.
Copy linkTweet thisAlerts:
@KorOct 01.2008 — Can you detail a little bit? What kind of arrays? Show us an array of yours. How are they named? Is that number appended to the name following an algorithm, or is random?
Copy linkTweet thisAlerts:
@DokOct 01.2008 — If the arrays are global variables and the name is myArray you can loop through them using
[CODE]// If array numbering start with 0
var i = 0;
var a = 'myArray' + i;
do {
// Array
windows[a]
i++;
a = 'myArray' + i;
}
while(windows[a]);[/CODE]
×

Success!

Help @Typhoon101 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...