Choosing next slide using Javascript random number

I'm wondering if it's possible to take a random number generated from Javascript, and to use that number to go to a particular slide.

This post (http://www.articulate.com/support/kb_article.php?product=st1&id=llwes8cn32vg) talks about about generating a random number with the code:

Generate a random number
This example generates a random number between 1 and 10.
[video demonstrations here and here; written explanation here]

var randomnumber = Math.floor((Math.random()*10)+1);
var player = GetPlayer();
player.SetVar("randnum",randomnumber);

Say, the random number generated is "8", I would like to redirect to say...slide 3.X (In this case "3.8").

The reason I'm trying this instead of using the question bank is: I read that if you link back to a question bank, it just goes through the same question path as the first pass through it. (http://community.articulate.com/forums/t/15739.aspx)

Any help would be greatly appreciated.

1 Reply
Bryan Tregunna

Lee, I hope you haven't been waiting for a response to this one for 7 years! Having just seen your post and noted no replies, I thought I would respond in case it helps others.

It seems to me that the easiest way is to create ten triggers: 

Jump to slide 3.1 on condition that randnum = 1

Jump to slide 3.2 on condition that randnum = 2

Jump to slide 3.3 on condition that randnum = 3

... and so on.

When using random numbers to trigger bear in mind that the randomness may mean that the same number is generated. You can overcome this by creating a T/F variable for each target slide, which turns to True when seen. You then place a trigger on this page to return to the random number generator if this variable is TRUE.