Board Logo

Tigra Scoller perform random file select
patgenie - 11/16/2004 at 01:09 AM

Is it possible to have the direct content feature select from the list in scroll_tpl0.js randomly? I assume this would require creating an array out of the image list.


rock - 11/18/2004 at 10:07 AM

I'm not sure I've understand you corectly.
If you want to setup value of 'content' key in template using some algorithm - why not?
ITEMS[n_item]['content'] = my_function_for_creating_content(n_item); //where n_item - index of scroller's item in ITEMS array.
Note: all modifications should be made before calling control's constructor.


Bosse - 1/31/2005 at 04:14 PM

This is how I did it. Don't know where you at, so I might overdo the explanation...

Replace:
-----------------------------------
<script language="JavaScript">
<!-- //
Tscroll_init(0); // Or whatever # u use
// -->
</script>
-----------------------------------

with:
-----------------------------------
<?
function slotnumber()
{
srand(time());
for ($i=0; $i < 1; $i++)
{
$random = (rand()%9);
$slot[] = $random;
}
print("$slot[0]");
print("$slot[1]");
print("$slot[2]");
print("$slot[3]");
print("$slot[4]");
print("$slot[5]");
print("$slot[6]");
print("$slot[7]");
print("$slot[8]");
print("$slot[9]"); // One for every document

}
?>

<script language="JavaScript">
<!-- //
Tscroll_init(<? slotnumber(); ?>);
// -->
</script>

-----------------------------------

($i=0; tell where to start. 0 for Tscroll_init(0), 1 for Tscroll_init(1)

< 1; $i++) tell how many figures (if you have f.x. 14 documents, write 2 - IMPORTANT! You then have to name all your documents with two figures, i.e. scroll.tpl00.js, scroll.tpl01.js, scroll.tpl02.js etc. And the same with the css files.)

(rand()%9) tell the range. If you have 14 documents, it should be 13 (since 0 counts)

/Bosse


Softcomplex: http://www.softcomplex.com/
Back to forum: http://www.softcomplex.com/forum/