Forum Moderators: open
// languages
var lang1 = 'English'
var lang2 = 'Irish'
// arrays for each menus
var themenus = new Array()
themenus[0] = 'tutorial_lang_new'
themenus[1] = 'tutorial_lang_1'
themenus[2] = 'tutorial_lang_2'
themenus[3] = 'tutorial_lang_3'
themenus[4] = 'tutorial_lang_4'
// contents for menu in foreach
for (x=0; x < 5; x++) {
var themenus[x] = new Array()
themenus[x][0] = '<a href="window.php?get='+themenus[x]+'&lang='+lang1+'">'+lang1+'</a>'
themenus[x][1] = '<a href="window.php?get='+themenus[x]+'&lang='+lang2+'">'+lang2+'</a>'
}
Here's what I'm trying to do:
I'm trying to get JS to declare each part of 'themenus' array as a var (like a foreach in PHP), but I know I've done it wrong, can anyone help me?
for (x=0; x < themenus.length ; x++)
Also, to save you having to keep count of how many elements there are, you could define the array as:
var themenus = new Array(
'tutorial_lang_new',
'tutorial_lang_1',
'tutorial_lang_2',
'tutorial_lang_3',
'tutorial_lang_4'
);