Need help

Community Beginner ,
Mar 21, 2021 Mar 21, 2021

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);

 

TOPICS
JavaScript

Views

61

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct Answers

Adobe Community Professional , Mar 21, 2021 Mar 21, 2021
Try add % before d, like this:"ID%s-%d"

Likes

Translate

Translate
Adobe Community Professional , Mar 21, 2021 Mar 21, 2021
Use this:((Math.random()*9000)+999);

Likes

Translate

Translate
Adobe Community Professional ,
Mar 21, 2021 Mar 21, 2021

Copy link to clipboard

Copied

Try add % before d, like this:

"ID%s-%d"

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 21, 2021 Mar 21, 2021

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?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 21, 2021 Mar 21, 2021

Copy link to clipboard

Copied

LATEST

Use this:

((Math.random()*9000)+999);

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines