Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.


Post Reply  Post Thread 

The JavaScript that Randomly Select the Quotes

Post Bank
Posting Manager
******

Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.

Signin to Remove this Post

ivenms
Administrator
*******


Posts: 2,177
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #1

The JavaScript that Randomly Select the Quotes


Here, Iam presenting a java script that will help you to present some quotes to your site which display a randomly selected quotes from a set of quotes.

The code goes as follows:

Code:
<script LANGUAGE="JavaScript">
//store the quotations in arrays
quotes = new Array(11);
authors = new Array(11);
quotes[0] = "Your quote 1 here";
authors[0] = "Author 1";
quotes[1] = "Your quote 2 here";
authors[1] = "Author 2";
quotes[2] = "Your quote 3 here";
authors[2] = "Author 3";
quotes[3] = "Your quote 4 here";
authors[3] = "Author 4";
quotes[4] = "Your quote 5 here";
authors[4] = "Author 5";
quotes[5] = "Your quote 6 here";
authors[5] = "Author 6";
quotes[6] = "Your quote 7 here";
authors[6] = "Author 7";
quotes[7] = "Your quote 8 here";
authors[7] = "Author 8";
quotes[8] = "Your quote 9 here";
authors[8] = "Author 9";
quotes[9] = "Your quote 10 here.";
authors[9] = "Author 10";
quotes[10] = "Your quote 11 here.";
authors[10] = "Author 11";

//calculate a random index
index = Math.floor(Math.random() * quotes.length);
//display the quotation
document.write("<DL>\n");
document.write("<DT>" + "\"" + quotes[index] + "\"\n");
document.write("<DD>" + "-- " + authors[index] + "\n");
document.write("</DL>\n");
//done
document.write("<br /><font size=1>Powered by: <a href='http://webmasters-forums.com'>WMF</a></font>");
</script>


You can add more quotes by adding the next array as:

Code:
quotes[11] = "Your quote 12 here.";
authors[11] = "Author 12";

Note that your array size also must be changed with the size of the array.

So enjoy the script by embedding this on your site.


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
26-07-2007 07:20 AM
Find all posts by this user Quote this message in a reply
walsh
Senior Member
****


Posts: 438
Group: Registered
Joined: Oct 2006
Status: Offline
Reputation: 0
Points: 764 (Donate)
Post: #2

RE: The script that Randomly Select the Quotes


This script is very useful one. I will insert this script on my web page.

It is very nice if I can see a running demo of this one.


26-07-2007 08:44 AM
Find all posts by this user Quote this message in a reply
ivenms
Administrator
*******


Posts: 2,177
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #3

RE: The script that Randomly Select the Quotes


You can see the demo on bottom of the page: http://webmasters-forums.com/sudoku/index.html


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
26-07-2007 04:27 PM
Find all posts by this user Quote this message in a reply
Cedik
Moderator
*****


Posts: 424
Group: Moderators
Joined: Aug 2007
Status: Away
Reputation: 2
Points: 575 (Donate)
Post: #4

RE: The script that Randomly Select the Quotes


Hmm... I allready have a plugin that automatically does that for the forum, but it would be interesting if I could intergrate it on my mkPortal too. I guess I could integrate that java script as a html block, right?
I tried to learn java once, and I knew some codes, but I never got this far.
Would a simple copy-paste work? Or I should include some <body> and other html tags too?


MyBB.ro|Extra.animezup.com|Picture with me ^^|Animezup.com|Forum.animezup.com|Manga-anime.ro|My blog^^
02-08-2007 07:10 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ivenms
Administrator
*******


Posts: 2,177
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #5

RE: The script that Randomly Select the Quotes


You can work javascript without embedding on HTML files by giving the coded file's extension as .js

Make a file name.js and embed this script on there.

Then on the html file, add the code:

Code:
<script src="file_path/name.js" type="text/javascript">
</script>


Thats all. It will perfectly work.


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
02-08-2007 05:21 PM
Find all posts by this user Quote this message in a reply
jimmy
Newbie


Posts: 21
Group: Registered
Joined: Sep 2007
Status: Offline
Reputation: 0
Points: 75 (Donate)
Post: #6

RE: The JavaScript that Randomly Select the Quotes


How would you alter the "quote" and "author" parts to pick and display a random css attribute?


"I am Jimmy, and I approve this message"
-Myself, 2007

My blog:
http://www.jimmyinc.com
19-09-2007 10:02 AM
Visit this user's website Find all posts by this user Quote this message in a reply
ivenms
Administrator
*******


Posts: 2,177
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #7

RE: The JavaScript that Randomly Select the Quotes


jimmy Wrote:
How would you alter the "quote" and "author" parts to pick and display a random css attribute?


What do you mean by random css attribute?


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
19-09-2007 11:39 AM
Find all posts by this user Quote this message in a reply
jimmy
Newbie


Posts: 21
Group: Registered
Joined: Sep 2007
Status: Offline
Reputation: 0
Points: 75 (Donate)
Post: #8

RE: The JavaScript that Randomly Select the Quotes


In my wordpress stylesheet for the theme, I have .subheader1, .subheader2, .subheader3 and so on. I want a javascript function to randomly pick one of those to display a random header, as I learned that the other way I tried is not possible with wordpress.


"I am Jimmy, and I approve this message"
-Myself, 2007

My blog:
http://www.jimmyinc.com
19-09-2007 08:42 PM
Visit this user's website Find all posts by this user Quote this message in a reply
ivenms
Administrator
*******


Posts: 2,177
Group: Administrators
Joined: Sep 2006
Status: Offline
Reputation: 14
Points: 4389 (Donate)
Post: #9

RE: The JavaScript that Randomly Select the Quotes


OK.

Iam suggesting a good and easy idea to get the effect.

Make a page: css.php. Then put the css code on the page and display the properties of tags on random when access the page. Simply embed the styles made by css.php on the blog theme. Thats all. You can make the styles different when accessing different time.

Hope that you understand the Idea i mentioned. Always here to help you. Smile


Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
19-09-2007 09:01 PM
Find all posts by this user Quote this message in a reply
godkillah
Senior Member
****


Posts: 261
Group: Registered
Joined: Sep 2007
Status: Offline
Reputation: 3
Points: 183 (Donate)
Post: #10

RE: The JavaScript that Randomly Select the Quotes


simple but nice,

would be more easy to do something like this though:

quotes[0] = ["Your quote 11 here.","Author 11"];


29-09-2007 01:46 AM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
Smile Learn JavaScript Basics ivenms 1 707 14-07-2008 06:20 PM
Last Post: ratedguy
Toungue Image Rollover Script Javascript ratedguy 0 107 14-07-2008 06:15 PM
Last Post: ratedguy
  I'm New to Javascript MaGiC DaN90 3 932 16-05-2008 04:37 PM
Last Post: ivenms
  Using iframes with javascript godkillah 0 1,755 26-01-2008 06:19 AM
Last Post: godkillah
Rolleyes JavaScript Redirection ivenms 0 666 15-09-2006 03:21 AM
Last Post: ivenms
Big Grin JavaScript Browser Detection ivenms 0 847 15-09-2006 03:20 AM
Last Post: ivenms
Smile JavaScript Alerts ivenms 0 668 15-09-2006 03:04 AM
Last Post: ivenms

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:

Forum Jump:

Sign In to Remove Ads

Download 1000's of web templates. Unlimited access!
World's Best Web Hosting
Resources

Recommended Sites:



Visit our Sponsors!

Current time: 22-11-2008, 03:32 AM


Copyright © 2002-2008 MyBB Group
Powered By MyBB