Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
115 views

Random Quote Alert (JavaScript Animation)

This document contains JavaScript code to randomly select and display a quote from an array of 10 quotes when a button is clicked. The code generates a random number between 1-10 to select a quote, then alerts the selected quote. A function gets a random number based on the current time or a random number generator. Another function calls the random number function, selects the quote using the random number, and alerts the selected quote when the button is clicked.

Uploaded by

Amit Sony
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views

Random Quote Alert (JavaScript Animation)

This document contains JavaScript code to randomly select and display a quote from an array of 10 quotes when a button is clicked. The code generates a random number between 1-10 to select a quote, then alerts the selected quote. A function gets a random number based on the current time or a random number generator. Another function calls the random number function, selects the quote using the random number, and alerts the selected quote when the button is clicked.

Uploaded by

Amit Sony
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Random Quote Alert

Insert into <BODY>

<SCRIPT language="JavaScript">
<!--
function get_random(maxNum)
{
if (Math.random && Math.round)
{
var ranNum= Math.round(Math.random()*(maxNum-1));
ranNum+=1;
return ranNum;
}
else
{
today= new Date();
hours= today.getHours();
mins= today.getMinutes();
secn= today.getSeconds();
if (hours==19)
hours=18;
var ranNum= (((hours+1)*(mins+1)*secn)%maxNum)+1;
return ranNum;
}
}

function getaQuote()
{
var maxQuotes=10;
var whichQuote=get_random(maxQuotes);
whichQuote--;

var quote=new Array(maxQuotes)


quote[0]="Quote #1";
quote[1]="Quote #2";
quote[2]="Quote #3";
quote[3]="Quote #4";
quote[4]="Quote #5";
quote[5]="Quote #6";
quote[6]="Quote #7";
quote[7]="Quote #8";
quote[8]="Quote #9";
quote[9]="Quote #10";

alert(quote[whichQuote]);
}
//-->
</SCRIPT>
<FORM name="form1">
<INPUT TYPE="button" value="Get a Quote!" onClick="getaQuote()">
</FORM>

You might also like