Click to See Complete Forum and Search --> : Javascript Help


96turnerri
09-08-2003, 08:05 PM
hi im a noob to java really only know the basics :( , im after a script, i would like this script to randomly disply a different message in the body of my page each time the page is opened, so i have a list of messages it can say, and then it randomly selects one, if anyone could help me id much appreciate it!

pyro
09-08-2003, 08:15 PM
Something like this should do it for you... Just make an array of all the items you'd like to have displayed.

<script type="text/javascript">
text = new Array("PHP Rules","Web Standards Rule","Programming Rules");
document.write(text[parseInt(Math.random()*text.length)]);
</script>

96turnerri
09-09-2003, 07:45 AM
hi thanks for the post ive had little luck building an array, lets say i want to display a b c d and e, if someone could show me how to build a working array, that would be great then i could edit it to show the real displays.

Rich

pyro
09-09-2003, 07:49 AM
My example above has the array prebuilt (line 2). Just change the values, and you're good to go...

96turnerri
09-09-2003, 07:51 AM
thanks pyro im such an idiot, i missed that completly i read build your own array then went off on one trying to build one lol

Many Thanks

pyro
09-09-2003, 07:53 AM
lol... no problem, man... :)

96turnerri
09-09-2003, 07:59 AM
just out of interest, how do you get a pic under your name, is that to do with you rank (how many posts youve sent)?

pyro
09-09-2003, 08:35 AM
No, the forums allow you to upload a custom avatar. Just go to your control panel, then to edit options. Down at the bottom there will be an option to change your avatar.

96turnerri
09-09-2003, 08:39 AM
thanks

pyro
09-09-2003, 08:46 AM
You bet... :)

96turnerri
09-09-2003, 08:56 AM
ty gonna start a new thread if you wana take a look, im gonna start a new one just because this ones getting quite long now lol