Call up random numbers

Is it possible to call up random numbers of 3 or 4 digits by clicking a button?
Let me explain: different digits appear each time I click on the same button.
Is it possible to accomplish this with Active Presenter? Thank you very much!

Call up random numbers

Random number generation can be done using JavaScript.

For example, you might do something like this for a number between 1 and 100

prez.variable("myVar",Math.floor(
  Math.random()*100
  )+1);

To generate a new random 3 or 4 digit number - you could use a strategy such as this.

On Slide Load

window.randomNumber = function(min, max) {
  return Math.floor((Math.random()*(max-min)+min))
};

On your button

prez.variable("myVar",randomNumber(100,9999));

If you have a shape on the slide to display your variable - you should see a new 3 or 4 digit number each time.

You can replace the minimum and maximum values as desired.

Hope this helps.

I am working on the intermediate JavaScript guide which includes a little discussion of random number generation as well. Be on the lookout for that to be posted in the next week.

3 Likes

WOW…you are a force Greg, thank you so much!
I have read more of your posts and have been fascinated.
Thank you from the bottom of my heart for your time and congratulations on your brilliance. :pray:

3 Likes