Generate Random Number In Javascript

RegisterLogin
Generate Random Number In Javascript
Post Description: The Page Will Show You Generate Random Number In Javascript Using A Simple Metho For Getting And Displaying A Random Number On Your Javascript Scripts
Tags: Generate, Random, Number, In, Javascript
This Post Was Posted On Jan 15, 2010 By Webune Tutorials #3051

Webune Offers Excellent Web Hosting

if you are visiting us today its probably because you want to know how you can generate random numbers using javascript code.

well, if thats the case, then you are in luck because, Webune Web Hosting is going to show you what code to use. generating random text is easy by using the Math.random() function so for example i have this code:

var example = Math.random();

were you able to see the javascript alert message. if so, this is the code we use to make that script:

JAVASCRIPT CODE:
<script type="text/javascript" language="javascript">
var randText = new Array ();
randText[0] = "linux";
randText[1] = "windows";
randText[2] = "mac";
randText[3] = "UNIX";
var i = Math.floor(4*Math.random())
alert('This is a Random Generated Message:\n\nThe Random Number is ' +i+ ', and its value is ' + randText[i] );
</script>
Leave Your Comments
Related Pages: [Add Your Website]
Post New Topic
©2012 Webune Forums - Sun Dec 16, 2012 11:05 am
Powered by: Webune Forums V3