15 replies [Last post]
JasonJJT
Offline
Regular
Last seen: 15 years 23 weeks ago
Timezone: GMT+5
Joined: 2003-08-11
Posts: 14
Points: 0

k

Tags:
Daniel
Daniel's picture
Offline
Enthusiast
Last seen: 43 weeks 3 days ago
Timezone: GMT+10
Joined: 2003-03-12
Posts: 76
Points: 0

Script for displaying a different daily text?

I know that KnightWolfJK has a similar system on his site.

There's a [url=http://www.csscreator.com/css-node/351 discussing this[/url], too.

JasonJJT
Offline
Regular
Last seen: 15 years 23 weeks ago
Timezone: GMT+5
Joined: 2003-08-11
Posts: 14
Points: 0

still need help

Thats with php, I need javascript because

1. my host doesnt support php
2. i dont know how to do it

Sven
Sven's picture
Offline
Enthusiast
Brisbane, Australia
Last seen: 15 years 4 weeks ago
Brisbane, Australia
Timezone: GMT+10
Joined: 2003-03-12
Posts: 166
Points: 0

Script for displaying a different daily text?

Here's a quick bit of code to display randomly from a set of options:

<html><body><script>

// random content for display
var options = new Array();
options[0] = "content one";
options[1] = "content two";
options[2] = "content three";
options[3] = "content four";

// random index into the array
var randomIndex = Math.floor(Math.random()*options.length);

// display something
document.write(options[randomIndex]);

</script></body></html>

The available options do have to be contained within the source HTML file, though, which could be a drawback, depending on how you intend to maintain them.

Daniel
Daniel's picture
Offline
Enthusiast
Last seen: 43 weeks 3 days ago
Timezone: GMT+10
Joined: 2003-03-12
Posts: 76
Points: 0

Script for displaying a different daily text?

Shifting to [url=http://www.csscreator.com/css-forum/10 Topic[/url] forum...

JasonJJT
Offline
Regular
Last seen: 15 years 23 weeks ago
Timezone: GMT+5
Joined: 2003-08-11
Posts: 14
Points: 0

Script for displaying a different daily text?

Thank you very much Sven.
Now how often does it display a random quote?
Does it show a different one every time the page is loaded?

KnightWolfJK
KnightWolfJK's picture
Offline
Enthusiast
Washington, DC
Last seen: 15 years 2 weeks ago
Washington, DC
Timezone: GMT-5
Joined: 2003-06-10
Posts: 210
Points: 0

Script for displaying a different daily text?

I highly recommend PHP or CGI scripts for this kind of thing, because they allow you to use a separate text file to stroe your quotes. But if you're limited to Javascript, try this one: http://javascript.internet.com/messages/rqt-quips.html

Diplomacy is the art of letting someone have your way

Daniel
Daniel's picture
Offline
Enthusiast
Last seen: 43 weeks 3 days ago
Timezone: GMT+10
Joined: 2003-03-12
Posts: 76
Points: 0

Script for displaying a different daily text?

Looks like the quotes change whenever the page is refreshed/reloaded.

Of course, as there are only 4 quotes in this example it's very likely that the next random quote will be exactly the same as the one before it.

Sven: Hope you don't mind me answering this one for you

JasonJJT: Hope you don't mind that I moved this one to Off Topic!

Sven
Sven's picture
Offline
Enthusiast
Brisbane, Australia
Last seen: 15 years 4 weeks ago
Brisbane, Australia
Timezone: GMT+10
Joined: 2003-03-12
Posts: 166
Points: 0

Script for displaying a different daily text?

Yeah, it's just a random choice every single time the page is loaded. Ah, now that I've re-read the original post, I see that it was supposed to just show a different quote for each day of the year. Oops... Tongue

Well, if you want to approach it in the same manner, you'd still set up the array of options, but instead of the random index, you'd use something like the day of the year. However, I agree with KWJK - a server-side means to manage this would be far superior.

Anyway, maybe we should take a step back and ask some questions:

(1) Whats the ultimate aim here? What's this whole different-quote-each-day thing about?

(2) What does your host support? Are there any server-side things you could take advantage of, or are you limited to just static html pages?

JasonJJT
Offline
Regular
Last seen: 15 years 23 weeks ago
Timezone: GMT+5
Joined: 2003-08-11
Posts: 14
Points: 0

Script for displaying a different daily text?

My ultimate aim is having a daily quote of the day in an iframe to be part of my homepage and blend in and match everything, and to get people checking back at the homepage daily to see the next quote.

What do you mean by server-side things? Not sure what these are. But my hosting package is very basic, so probably not.

Thank you very much for your continued help

KnightWolfJK
KnightWolfJK's picture
Offline
Enthusiast
Washington, DC
Last seen: 15 years 2 weeks ago
Washington, DC
Timezone: GMT-5
Joined: 2003-06-10
Posts: 210
Points: 0

Script for displaying a different daily text?

Well, let's try this- can you provide a link to your webhost's hosting package? For example, I'm using Hostway's Gold Plus Plan.

Diplomacy is the art of letting someone have your way

JasonJJT
Offline
Regular
Last seen: 15 years 23 weeks ago
Timezone: GMT+5
Joined: 2003-08-11
Posts: 14
Points: 0

Script for displaying a different daily text?

Sure it is

http://www.doteasy.com/

the basic $0 free plan.

KnightWolfJK
KnightWolfJK's picture
Offline
Enthusiast
Washington, DC
Last seen: 15 years 2 weeks ago
Washington, DC
Timezone: GMT-5
Joined: 2003-06-10
Posts: 210
Points: 0

Script for displaying a different daily text?

For reference purposes, your server-side options (CGI, Perl, SSI, PHP, MySQL) are available with Doteasy's Ultra plan. This script should accomplish what you're looking for.

Good Luck...

Diplomacy is the art of letting someone have your way

JasonJJT
Offline
Regular
Last seen: 15 years 23 weeks ago
Timezone: GMT+5
Joined: 2003-08-11
Posts: 14
Points: 0

Script for displaying a different daily text?

Thank you very much, I appreciate it.
Will look into it

david_sakh
Offline
newbie
Last seen: 17 years 18 weeks ago
Joined: 2005-02-25
Posts: 1
Points: 0

here's another good script

You could use this random text generator. It's a PHP script, so you have to have PHP enabled on your website to use it. It works for me.

fambi
Offline
Enthusiast
Last seen: 14 years 6 weeks ago
Joined: 2004-08-26
Posts: 269
Points: -1

Script for displaying a different daily text?

Funnily enough, i just finsihed my random image code.

I originally had a collection of complicated codes, but php has its own function to do what you want:

<?php
$quotes = array("quote 1", "quote 2", "quote 3", "quote 4", "quote 5", "quote 6", "quote 7");
$random_quote = $quotes [array_rand($quotes )];
print $random_quote;
?>

That's it, nothing else, nothing more!!! Simple and effective.