Click here to Skip to main content
16,015,809 members

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] ==