![]() |
|
|||||||
| Register | FAQ | Members List | Arcade | Dev Directory | HB Bank | Calendar | Search | Today's Posts | Mark Forums Read |
| JavaScript Programming Discuss javascript coding. |
| Have A Look At Some Of Our Webmaster Related Sponsors! | |||||
![]() Script Directory |
![]() Advertise Here |
![]() Market Leverage |
![]() Free Templates |
![]() 3D Guide-characters |
![]() Advertise Here |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|
#1 (permalink) |
|
Junior Member
|
a very simple javascript to generate random quotes at any place of a webpage you want it to appear and any quote which you want to appear. Just insert this script in your webpage wherever you want the random quote to appear.
remember change quotes with yours Code:
<script language="JavaScript">
var Quotation=new Array()
Quotation[0] = "Time is of the essence! Comb your
hair.";
Quotation[1] = "Sanity is a golden apple with no
shoelaces.";
Quotation[2] = "The image is more than an idea. It
is a vortex or cluster of fused ideas and is endowed
with energy. ~ Ezra Pound";
Quotation[3] = "Honesty blurts where deception
sneezes.";
Quotation[4] = "Pastry satisfies where art is
unavailable.";
Quotation[5] = "Image creates desire. You will
what you imagine. ~ J. G. Gallimore";
Quotation[6] = "The image cannot be dispossessed
of a primordial freshness, which idea can never
claim. An idea is derivative and tamed. The image
is in the natural or wild state, and it has to be
discovered there, not put there, obeying its own
law and none of ours. ~John Crowe Ransom";
Quotation[7] = "Wishes are like goldfish with
propellors.";
Quotation[8] = "Love the river's \"beauty\", but live
on a hill.";
Quotation[9] = "Invention is the mother of too
many useless toys.";
Quotation[10] = "I want to know God's thoughts...
the rest are details.~ Albert Einstein ";
//
======================================
// Do not change anything below this line
//
======================================
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*
(Q-1));
function showQuotation(){document.write(Quotation
[whichQuotation]);}
showQuotation();
</script></p>
|
|
|
|
|
|
#2 (permalink) | |||
|
Administrator
|
Very simple, yet cool javascript code. In case any one is interested I will breifly explain what is happining in the code. I gave you reputation for this useful code to the community!
1. First it makes a variable called "Quotation" and make it an array (an array is basically a variable that holds several variables. 2. Now it sets the different variables inside the array. Quotation[1] is the first variable inside the Quotation array, so you just increase the number to add another variable (which we are setting to contain quotes), so you could have 50 quotes if you wanted to! Now the part that is a bit more complicated: Quote:
Quote:
Quote:
sneezes.".) If this was confusing to you, don't worry. Just copy and paste that to the spot in your website you want a random quote, then change the quotes to ones you want, or even things that aren't quotes, and it will work fine. You can change the number of quoates as well, by just adding in a new variables that goes up one, so if you wanted 1 extra quote the ones already there you would just add this after the end of the 10th quote: Quotation[11] = "Your quote here"; |
|||
|
|
|
|
|
#6 (permalink) |
|
New Hunter
Join Date: Dec 2007
Location: United Kingdom - Dorset - Bournemouth
Posts: 88
iTrader: 0 / 0%
Hunter Bux: 5.00
![]() ![]() |
My Attempt:
Code:
function Random_Note()
{
var note = new Array(6)
var Select = Random();
note[0] = "Quote";
note[1] = "Quote";
note[2] = "Quote";
note[3] = "Quote";
note[4] = "Quote";
note[5] = "Quote";
document.getElementById('Random').innerHTML = "<b>" + note[Select] + "</b>";
var Time = setTimeout("Random_Note()", 1500);
}
function Random()
{
var Random_Number_Selection = Math.floor(Math.random()*6);
return Random_Number_Selection;
}
__________________
<!-- I can type the entire Alphabet in 2.19 seconds --> /* (X/D)Html, Css, Javascript, Ajax, Xml (DTD), PHP, MySQL, E4X */ /* Learning C++ and German */ |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|