View Single Post
Old 03-23-2009, 04:24 AM   #3 (permalink)
Ralph
Senior Member
 
Join Date: Oct 2007
Posts: 341
Ralph is on a distinguished road
Default

Thanks a lot runningbird.

I followed your directions and unfortunately it didn't work. Luckily, I managed to find a script that worked out for me. I did nothing but paste this in the place it appeared:

Code:
<script type="text/javascript">
// <![CDATA[
Array.prototype.random = function(limit)
{
	if (typeof limit == 'undefined' || limit < 0) limit = 1;
	else if (!limit) limit = this.length;
	for (var i = 0, source = this, target = new Array(), n = source.length; i < limit && n > 0; i++)
	{
		do { var index = Math.random(); } while (index == 1);
		index = Math.floor(index * n);
		target.push(source[index]);
		source[index] = source[--n];
	}
	return target;
}

document.write(new Array(
// Enter the elements here:

'Tekst 1',
'Tekst 2',
'Tekst 3'

).random().join(''));
// ]]>
</script>

I opt for one more tweak. Perhaps you could help me out. Therre are two paragraphs in the place for my quotes. The difference between them is style (class="para1" and class="para2"):

<p class="para1">Quisque sed felis. </p>

<p class="para2">Quisque sed felis. </p>


I pasted my script inside the <p class="para1"> </p> and it worked out well. I would like to place the quote author in <p class="para2"> </p>. I can't do that by placing the same script because the author would be chosen randomly, instead of according to the chosen quote. So there are two ways in which you could help me out:

1. Verify the script code and make it write two paragraphs with style defined instead of just plain text

2. Create a javascript that uses the same variable as the first one in choosing between the texts. This way, if the quote 2 would be chosen in the first script, the second script would automatically choose author 2. I could make the list of authors corresponding to the list of quotes.




Thanks a lot and looking forward to hearing from you again


UPDATE: Help! This script works only for 3 quotes. When I add fourth one, nothing shows up. Where can I change the max. number of quotes? Please help

Ralph

Last edited by Ralph; 03-23-2009 at 09:04 PM.
Ralph is offline   Reply With Quote