Copy link to clipboard
Copied
Hi, I'm trying to use code from @Thom Parker tutorial:
https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings/
But instead of 4 digit number I get only "d", what am I doing wrong?
Here is code I just copy/paste it, I didn't change anything:
var strDate = "3/20/2006"; // Starting Date
var strFirstPart = strDate.split("/").join("");
var nSecondPart = Math.random()*10000;
var strRegNum = util.printf("ID%s-d", strFirstPart, nSecondPart);
Try add % before d, like this:
"ID%s-%d"
Use this:
((Math.random()*9000)+999);
Copy link to clipboard
Copied
Try add % before d, like this:
"ID%s-%d"
Copy link to clipboard
Copied
Thank you that fixed it.
In tutorial it says Il get 4 digit number but sometimes I get 3 digits, How to only get 4 digits every time?
Copy link to clipboard
Copied
Use this:
((Math.random()*9000)+999);