0

I need to generate string value in form "000x" (it will be inserted into database). I get the value (x-1) from database, so the starting values of number x and string are 1 and "0001". If last string in database is for example "0007", the x value is 8 and next string to be inserted is "0008". Number of zeros before x depends on whether x is single digit, two digit, three digit or four digit number (let put constraint on x max value to 9999).

"0009" "0099" "0999" "9999"

How can I get output string "000x" for input number x (taking care about number of zeros in front of x)?

  • @qyre I didn't find the duplicate question (I wouldn't post this if I did). Please, can you provide link to duplicate? –  Mar 04 '17 at 20:58
  • 1
    http://stackoverflow.com/questions/10073699/pad-a-number-with-leading-zeros-in-javascript – Jordan Bonitatis Mar 04 '17 at 21:02

0 Answers0