Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number to Word - jquery

Anyone know's a way to describe a cash value or a plugin who does that ?

exp: if i have $ 1.200.000,00 and the user hover() the value: description will be "one million two hundred "

Thanks!

like image 610
Ricardo Binns Avatar asked Aug 31 '11 13:08

Ricardo Binns


2 Answers

The following page mentions a very simple implementation:

Number to Words | Javascript

which can perform the conversion by using this function:

var words = toWords(num);

Using jQuery, you can wrap this inside of your hover function, as shown below:

//This will add a tooltip upon hovering with the "word" value.
$('div').hover(function(){
    $(this).attr('title',toWords($(this).text()));
});

Working Demo

like image 167
Rion Williams Avatar answered Oct 18 '22 22:10

Rion Williams


Should check the source of this example, with some modification you should be able to achieve this:

http://abhisanoujam.blogspot.com/2009/07/having-fun-with-jquery-numbers-to-words.html

like image 44
dciso Avatar answered Oct 19 '22 00:10

dciso