Hi Guys,
Were formulating quotations with the ability to translate the summary total price in numbers to words.
Ie. 1010 = One thousand ten.
I have some codes in java and I tried to use it using of custom html fields. Its working in html field in draft however we want to able to fill this value (word value) in the other field (single line field or Multiline field) therefore we can also record the data in our SQL. Hope somebody could help how to add this code on my fields.
Image of the fields :
JavaScript Code:
var th = ['','thousand','million', 'billion','trillion'];var dg = ['zero','one','two','three','four', 'five','six','seven','eight','nine']; var tn = ['ten','eleven','twelve','thirteen', 'fourteen','fifteen','sixteen', 'seventeen','eighteen','nineteen'];var tw = ['twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety']; function toWords(s){ s = s.toString(); s = s.replace(/[\, ]/g,''); if (s != parseFloat(s)) return 'not a number'; var x = s.indexOf('.'); if (x == -1) x = s.length; if (x > 15) return 'too big'; var n = s.split(''); var str = ''; var sk = 0; for (var i=0; i < x; i++) { if ((x-i)%3==2) { if (n[i] == '1') { str += tn[Number(n[i+1])] + ' '; i++; sk=1; } else if (n[i]!=0) { str += tw[n[i]-2] + ' '; sk=1; } } else if (n[i]!=0) { str += dg[n[i]] +' '; if ((x-i)%3==0) str += 'hundred '; sk=1; } if ((x-i)%3==1) { if (sk) str += th[(x-i-1)/3] + ' '; sk=0; } } if (x != s.length) { var y = s.length; str += 'point '; for (var i=x+1; i<y; i++) str += dg[n[i]] +' '; } return str.replace(/\s+/g,' ');}
Tnx,
Cherry