|
-
Aug 29th, 2003, 04:08 PM
#1
Thread Starter
Registered User
Need help with basic Javascript thing
I want to put a script on an HTML page that will show up a random text or number from a list.
Like, whenever I reload the page, a random text appears on the page or something like that.
Thanks
-
Aug 29th, 2003, 07:14 PM
#2
Fanatic Member
Something like this should work. It could probably be cleaned up a bit, but you should be able to get the picture. Just copy and past the code into a new HTML file to give it a try:
Code:
<script langauge="JavaScript">
var aList = new Array();
var ALC = 0;
aList[ALC++] = "I Feel Great"
aList[ALC++] = "I Feel Sick"
aList[ALC++] = "I Feel Stupid"
function ShowRndMsg(){
var sMsg
var iRnd = Math.round(Math.random() * (ALC-1))
sMsg = aList[iRnd];
return sMsg;
}
</script>
This is some test text<br><br>
<script language="JavaScript">
document.writeln("How I Feel: <b>" + ShowRndMsg() + "</b>");
</script>
<br><br>
This is some more test text.
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Aug 30th, 2003, 10:25 PM
#3
Thread Starter
Registered User
Thanks a lot man
-
Aug 31st, 2003, 09:35 AM
#4
Fanatic Member
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|