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 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Script to calculate amount of digits in a given number. - Willing to pay for this.

    Hi,
    I am not very experienced in JavaScript, so I need some help here. I've had a look around the net but I can't seem to find this.

    I am looking for a simple script that will calculate the amount of digits in a given number entered in a text box and output the value into a different text box or preferably a hidden value.

    For example:

    1 would be 1 digit.
    01 would be 2 digits.
    10 would be 2 digits
    100 would be three digits.

    And so on.

    I need this so I can calculate the cost of a door number. Numerals cost £2.00 each so I need the form I am building to calculate the cost of a door number. I need this to be a script that calculates on the fly without going to a separate page.

    This is quite important so I would be willing to pay a small fee if someone could write this for me, I will pay via PayPal. I am 100% serious no BS as I need this ASAP.

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,391
    Thanks
    11
    Thanked 568 Times in 561 Posts
    How much are you willing to pay for four lines of code? ;-)
    Code:
    var myDestinationBox = document.getElementById('IDofdestinationbox');
    var myDigitBox = document.getElementById('IDofdigittextbox');
    var valueOfDigits = parseInt(myDigitBox.value, 10);
    if(!NaN(valueOfDigits)) myDestinationBox.value = myDigitBox.value.length;

  • #3
    New Coder
    Join Date
    Jul 2011
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Haha, I said I didn't know JavaScript. I also didn't' search very well as I found what I needed as soon as I had posted this.

    Thank you for your input.

    Sorry to be a pain.


  •  

    Posting Permissions

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