TinyPortal

Development => Block Codes => Topic started by: Sharr76 on February 20, 2007, 09:48:15 AM

Title: Very Simple Slogan Script
Post by: Sharr76 on February 20, 2007, 09:48:15 AM
I have added this simple script to a scriptbox and it works great! Does anyone know how to make this script rotate?

<SCRIPT>
/*
Script obtained from Wsabstract.com
For this script and more
Visit Java-Scripts.net or Wsabstract.com
*/

quote0= "Wipe Up and avoid a Slip Up!.";
quote1= "We need you! Work safely. ";
quote2= "Working without Safety is a Dead-End Job. ";

var ran_unrounded=Math.random()*2;
var ran_number=Math.round(ran_unrounded);

document.write(eval("quote"+ran_number));
</SCRIPT>
Title: Re: Very Simple Slogan Script
Post by: G6Cad on February 20, 2007, 11:21:42 AM
If you use the random quote snippets you have the same thing, just change the textstrings in that snippet to your own slogan strings and away you go  :D
Title: Re: Very Simple Slogan Script
Post by: Crip on February 20, 2007, 11:44:37 AM
...in my php "random quotes' I now have around 700 diff./ quotes. :)
Title: Re: Very Simple Slogan Script
Post by: Sharr76 on February 20, 2007, 12:28:16 PM
I cant get random quote snippets to work for me
Title: Re: Very Simple Slogan Script
Post by: JPDeni on February 20, 2007, 01:18:28 PM
Try this one in a php block:


$quotes = array (
"Wipe Up and avoid a Slip Up!",
"We need you! Work safely.",
"Working without Safety is a Dead-End Job."
);

shuffle($quotes);

echo $quotes[0];


Add more quotes to the array as you wish.
Title: Re: Very Simple Slogan Script
Post by: Sharr76 on February 20, 2007, 03:00:52 PM
Thanks JPDeni,

is there any way we can get this to scroll?
Title: Re: Very Simple Slogan Script
Post by: akulion on February 20, 2007, 03:04:35 PM
u could try moving from side to side...creates a scrolling effect lol

JJ
Title: Re: Very Simple Slogan Script
Post by: JPDeni on February 20, 2007, 03:13:48 PM
Quote from: Sharr76 on February 20, 2007, 03:00:52 PM
Thanks JPDeni,

is there any way we can get this to scroll?

Scroll? Like

This is scrolling

Just add a marquee tag

So instead of


echo $quotes[0];


use


echo '<marquee>' , $quotes[0] , '</marquee>';


You can look up the various options that are available with the tag. And you can format your quote however you want, using a similar structure to the above.

If you mean something different by "scrolling," you'll need to explain a little more.  :)
Title: Re: Very Simple Slogan Script
Post by: Sharr76 on February 20, 2007, 03:20:09 PM
No this is just fine...but it scrolls the same slogan until the page is refreshed. Can we get it to scroll all slogans one after the other....? whithout having to refresh the page?

http://www.ndex.org/index.php (http://www.ndex.org/index.php)
Title: Re: Very Simple Slogan Script
Post by: JPDeni on February 20, 2007, 04:25:03 PM
QuoteCan we get it to scroll all slogans one after the other....? whithout having to refresh the page?
We?  ;) Yeah, I think I can do that. You'll have to work with it to see the best spacing between them and change the number in line 2.


$space = '&nb' . 'sp;';
$spaces = str_repeat($space,20); // change the number to change the number of spaces between the slogans

$quotes = array (
"Wipe Up and avoid a Slip Up!",
"We need you! Work safely.",
"Working without Safety is a Dead-End Job."
);

shuffle($quotes);

$string = implode($spaces,$quotes);

echo '<marquee>' , $string , '</marquee>';
Title: Re: Very Simple Slogan Script
Post by: Sharr76 on February 20, 2007, 04:40:23 PM
 :coolsmiley: Thanks alot, this is excellent....... ;) how can you slow it down a little..... :)
Title: Re: Very Simple Slogan Script
Post by: JPDeni on February 20, 2007, 04:47:42 PM
There's lots of information about how to adjust the marquee tag here (http://www.quackit.com/html/codes/html_marquee_code.cfm). It shows a lot of different options that you can play with. :)