|
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,179
Group: Administrators
Joined: Sep 2006
Status:
Offline
Reputation: 14
Points: 4389 (Donate)
|
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:
<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:
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 |
|
|
walsh
Senior Member
   
Posts: 401
Group: Registered
Joined: Oct 2006
Status:
Offline
Reputation: 0
Points: 680 (Donate)
|
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 |
|
|
ivenms
Administrator
      
Posts: 2,179
Group: Administrators
Joined: Sep 2006
Status:
Offline
Reputation: 14
Points: 4389 (Donate)
|
|
| 26-07-2007 04:27 PM |
|
|
Cedik
Moderator
    
Posts: 424
Group: Moderators
Joined: Aug 2007
Status:
Away
Reputation: 2
Points: 575 (Donate)
|
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 |
|
|
ivenms
Administrator
      
Posts: 2,179
Group: Administrators
Joined: Sep 2006
Status:
Offline
Reputation: 14
Points: 4389 (Donate)
|
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:
<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 |
|
|
jimmy
Newbie
Posts: 21
Group: Registered
Joined: Sep 2007
Status:
Offline
Reputation: 0
Points: 75 (Donate)
|
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 |
|
|
ivenms
Administrator
      
Posts: 2,179
Group: Administrators
Joined: Sep 2006
Status:
Offline
Reputation: 14
Points: 4389 (Donate)
|
|
| 19-09-2007 11:39 AM |
|
|
jimmy
Newbie
Posts: 21
Group: Registered
Joined: Sep 2007
Status:
Offline
Reputation: 0
Points: 75 (Donate)
|
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 |
|
|
ivenms
Administrator
      
Posts: 2,179
Group: Administrators
Joined: Sep 2006
Status:
Offline
Reputation: 14
Points: 4389 (Donate)
|
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.
Read: General Rules & Policies before posting.
Make Money By Posting | Earning and Exchanging Points | Add Your Links
|
|
| 19-09-2007 09:01 PM |
|
|
godkillah
Senior Member
   
Posts: 261
Group: Registered
Joined: Sep 2007
Status:
Offline
Reputation: 3
Points: 183 (Donate)
|
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 |
|
|