16,015,809 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by ManjuDipu (Top 1 by date)
ManjuDipu
20-Jun-12 5:27am
View
Deleted
function convertNumberToWords(amount) {
var junkVal = amount; // document.getElementById('txtDetailedNarration').value;
//var intActualcount = junkVal.length;
junkVal = Math.floor(junkVal);
var obStr = new String(junkVal);
numReversed = obStr.split("");
actnumber = numReversed.reverse();
//var intCount = obStr.length;
if (Number(junkVal) >= 0) {
//do nothing
}
else {
alert('wrong Number cannot be converted');
return '';
}
if (Number(junkVal) == 0) {
//document.getElementById('divinwords').innerHTML = obStr + '' + 'Rupees Zero Only'; // $('#cnt-box').innerHTML = obStr + '' + 'Rupees Zero Only'; //
//document.getElementById('divinwords').innerHTML = obStr + '' + 'Zero'; // $('#cnt-box').innerHTML = obStr + '' + 'Rupees Zero Only'; //
return 'Zero';
}
if (actnumber.length > 12) {
alert('Cannot convert ' + actnumber.length + ' digit number'); //Oops!!!! the Number is too big to covertes
return '';
}
var iWords = ["Zero", " One", " Two", " Three", " Four", " Five", " Six", " Seven", " Eight", " Nine"];
var ePlace = ['Ten', ' Eleven', ' Twelve', ' Thirteen', ' Fourteen', ' Fifteen', ' Sixteen', ' Seventeen', ' Eighteen', ' Nineteen'];
var tensPlace = ['dummy', ' Ten', ' Twenty', ' Thirty', ' Forty', ' Fifty', ' Sixty', ' Seventy', ' Eighty', ' Ninety'];
var hundsPlace = ['dummy', ' One Hundred', ' Two Hundred', ' Three Hundred', ' Four Hundred', ' Five Hundred', ' Six Hundred', ' Seven Hundred', ' Eight Hundred', ' Nine Hundred'];
var thousPlace = ['dummy', ' One Thousand', ' Two Thousand', ' Three Thousand', ' Four Thousand', ' Five Thousand', ' Six Thousand', ' Seven Thousand', ' Eight Thousand', ' Nine Thousand'];
var tensthousPlace = ['dummy', ' Ten Thousand', ' Twenty Thousand', ' Thirty Thousand', ' Forty Thousand', ' Fifty Thousand', ' Sixty Thousand', ' Seventy Thousand', ' Eighty Thousand', ' Ninety Thousand'];
var iWordsLength = numReversed.length;
var totalWords = "";
var inWords = new Array();
var finalWord = "";
j = 0;
for (i = 0; i < iWordsLength; i++) {
switch (i) {
case 0:
if (actnumber[i] == 0 || actnumber[i + 1] == 1) {
inWords[j] = '';
}
else {
inWords[j] = iWords[actnumber[i]];
}
inWords[j] = inWords[j]; // +' Only';
break;
case 1:
tens_complication();
break;
case 2:
if (actnumber[i] == 0) {
inWords[j] = '';
}
else if (actnumber[i - 1] != 0 && actnumber[i - 2] != 0) {
//inWords[j] = iWords[actnumber[i]] + ' Hundred and';
inWords[j] = iWords[actnumber[i]] + ' Hundred ';
}
else {
inWords[j] = iWords[actnumber[i]] + ' Hundred';
}
break;
case 3:
if (actnumber[i] == 0 || actnumber[i + 1] == 1) {
inWords[j] = '';
}
else {
inWords[j] = iWords[actnumber[i]];
}
if (actnumber[i + 1] != 0 || actnumber[i] > 0) {
inWords[j] = inWords[j] + " Thousand";
}
break;
case 4:
tens_complication();
break;
case 5:
if (actnumber[i] == 0 || actnumber[i + 1] == 1) {
inWords[j] = '';
}
else {
inWords[j] = iWords[actnumber[i]];
}
inWords[j] = inWords[j] + " Lakh";
break;
case 6:
tens_complication();
break;
case 7:
if (actnumber[i] ==