Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-18-2011, 04:48 PM   PM User | #1
Seb Meikle
New Coder

 
Join Date: Jul 2011
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Seb Meikle can only hope to improve
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.
Seb Meikle is offline   Reply With Quote
Old 07-18-2011, 05:13 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 530 Times in 524 Posts
devnull69 will become famous soon enough
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;
devnull69 is offline   Reply With Quote
Old 07-18-2011, 05:18 PM   PM User | #3
Seb Meikle
New Coder

 
Join Date: Jul 2011
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Seb Meikle can only hope to improve
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.
Seb Meikle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:36 PM.


Advertisement
Log in to turn off these ads.