[thelist] javascript question on formatting numbers.
Alliax
damiencola at wanadoo.fr
Thu Dec 20 18:35:30 CST 2001
Thank you Rudy, I have been thinking of constructing the string myself too,
cheers for showing it to me.
In fact I wanted to know if it was possible to set a format, like in c
int num = 15;
printf("here is my 5 digits number : %5d !", num);
would output:
here is my 5 digits number : 00015 !
Well, at least that what I remember from my C courses even if I don't practise
the printf..
But your function is fine for outputting results as strings, thank you.
> <script language="JavaScript"><!--
> function pad(number,length) {
> var str = '' + number;
> while (str.length < length)
> str = '0' + str;
> return str;
> }
> // --></script>
Cordialement,
__ Alliax ~CV : http://LingoParadise.com/cv.php
Un site pour Toulon : http://ToulonParadise.com
Un site pour Renaud : http://rfaucilhon.multimania.com
Un site pour Director : http://LingoParadise.com
More information about the thelist
mailing list