Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    value of my variable is 1, i want 001

    value of my variable is 1, i want to format its output as 001
    how to do this?
    thanks

  • #2
    New Coder
    Join Date
    May 2006
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Something like this could work:

    Code:
    <script language="JavaScript">
    <!--
    function pad(number,length) {
        var str = '' + number;
        while (str.length < length)
            str = '0' + str;
        return str;
    }
    
    alert(pad(2,5));
    //-->
    </script>
    http://www.irt.org/script/183.htm

    Good luck

  • #3
    New to the CF scene
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks
    but it sais "00002"

  • #4
    New to the CF scene
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok, i got it
    thank a lot!

  • #5
    New to the CF scene
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    and what about analogue with VBscript?

  • #6
    New to the CF scene
    Join Date
    May 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    found it

    n=1 'an integer
    s=right("000" & n,3) 'a string
    msgbox s


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •