/    Sign up×
Community /Pin to ProfileBookmark

Javascript Help

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!

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@pyroSep 09.2003 — 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>
Copy linkTweet thisAlerts:
@96turnerriauthorSep 09.2003 — 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
Copy linkTweet thisAlerts:
@pyroSep 09.2003 — My example above has the array prebuilt (line 2). Just change the values, and you're good to go...
Copy linkTweet thisAlerts:
@96turnerriauthorSep 09.2003 — 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
Copy linkTweet thisAlerts:
@pyroSep 09.2003 — lol... no problem, man... ?
Copy linkTweet thisAlerts:
@96turnerriauthorSep 09.2003 — 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)?
Copy linkTweet thisAlerts:
@pyroSep 09.2003 — 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.
Copy linkTweet thisAlerts:
@96turnerriauthorSep 09.2003 — thanks
Copy linkTweet thisAlerts:
@pyroSep 09.2003 — You bet... ?
Copy linkTweet thisAlerts:
@96turnerriauthorSep 09.2003 — 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
×

Success!

Help @96turnerri 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.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

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