Skip to main content
Known Participant
October 21, 2024
Answered

I want to create a button that takes the user to a random page but within specified pages.

  • October 21, 2024
  • 1 reply
  • 493 views

I want to create a button that takes the user to a random page but within specified pages. For example, if I have a document that is 100 pages long, I want a button to take the user to a random page but only between pages 40-90 can this be done? If so, how?

This topic has been closed for replies.
Correct answer Nesa Nurani

You can simplify it a bit:

var page = Math.floor(Math.random() * 51) + 40;
this.pageNum = page - 1;

1 reply

PDF Automation Station
Community Expert
Community Expert
October 21, 2024

var page;
var num=new Date().getTime().toString();
var num2=Number(num.slice(num.length-2));
if(num2<=40)
{page=num2+41}
else if(num2>40 && num2<90)
{page=num2}
else
{page=num2-41}

this.pageNum=page-1;

Nesa Nurani
Community Expert
Nesa NuraniCommunity ExpertCorrect answer
Community Expert
October 21, 2024

You can simplify it a bit:

var page = Math.floor(Math.random() * 51) + 40;
this.pageNum = page - 1;