Hello FWS!
It's been a good few years since I've done much coding of anything. I've started again since I've done bits here and there in work and I'm trying to re-do my personal website. The thing I'm having an issue with is having a area of my site display different languages of "Hello", selecting them from an array. The code itself works, but how its displaying on the page isn't.
So that's the code, used Google for the translations. If you check the screenshot, you can see its loading another random string from the array and displaying it at the very top of the page. When I first tested it with only about 5 strings it worked fine, displaying only on the menubar (and not the top) but it was showing undefined every once in a while. Adding over 10 or so strings removes that but now it is constantly displaying twice.
Any ideas why it's doing this? Or a cleaner better way to do it (like Flickr has?)
It's been a good few years since I've done much coding of anything. I've started again since I've done bits here and there in work and I'm trying to re-do my personal website. The thing I'm having an issue with is having a area of my site display different languages of "Hello", selecting them from an array. The code itself works, but how its displaying on the page isn't.
Code:
var HelloWorld = new Array()
HelloWorld[1] = 'Hello',
HelloWorld[2] = 'Hallo',
HelloWorld[3] = 'Përshëndetje',
HelloWorld[4] = 'مرحبا',
HelloWorld[5] = 'Բարեւ Ձեզ',
HelloWorld[6] = 'Salam',
HelloWorld[7] = 'Kaixo',
HelloWorld[8] = 'Прывітанне',
HelloWorld[9] = 'Здравейте',
HelloWorld[10] = 'Hola',
HelloWorld[11] = '你好',
HelloWorld[12] = 'Bok',
HelloWorld[13] = 'Ahoj',
HelloWorld[14] = 'Hej',
HelloWorld[15] = 'Saluton',
HelloWorld[16] = 'Tere',
HelloWorld[17] = 'Hei',
HelloWorld[18] = 'Bonjour',
HelloWorld[19] = 'Ola',
HelloWorld[20] = 'გამარჯობა',
HelloWorld[21] = 'Γεια σας',
HelloWorld[22] = 'હેલો',
HelloWorld[23] = 'Alo',
HelloWorld[24] = 'שלום',
HelloWorld[25] = 'Helló',
HelloWorld[26] = 'नमस्ते',
HelloWorld[27] = 'Dia duit',
HelloWorld[28] = 'Ciao',
HelloWorld[29] = 'もしもし',
HelloWorld[30] = '안녕하세요.',
HelloWorld[31] = 'Salve',
HelloWorld[32] = 'Sveiki',
HelloWorld[33] = 'Здраво',
HelloWorld[34] = 'سلام',
HelloWorld[35] = 'Olá',
HelloWorld[36] = 'привет',
HelloWorld[37] = 'Pozdravljeni',
HelloWorld[38] = '¡Hola',
HelloWorld[39] = 'Wapendwa',
HelloWorld[40] = 'Hallå',
HelloWorld[41] = 'வணக்கம்',
HelloWorld[42] = 'สวัสดี',
HelloWorld[43] = 'Merhaba',
HelloWorld[44] = 'Привіт',
HelloWorld[45] = 'خوش',
HelloWorld[46] = 'Chào',
HelloWorld[47] = 'Helo',
HelloWorld[48] = 'העלא';
var EchoWorld = HelloWorld[Math.floor(Math.random() * HelloWorld.length)];
document.write(EchoWorld);
So that's the code, used Google for the translations. If you check the screenshot, you can see its loading another random string from the array and displaying it at the very top of the page. When I first tested it with only about 5 strings it worked fine, displaying only on the menubar (and not the top) but it was showing undefined every once in a while. Adding over 10 or so strings removes that but now it is constantly displaying twice.
Any ideas why it's doing this? Or a cleaner better way to do it (like Flickr has?)