Read the number in English


/ Published in: HTML
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <title>Eppol Number Reader</title>
  6. </head>
  7.  
  8. <div align="center">
  9. <div style=
  10. "text-align=center;font-family:Tahoma;font-size:8pt;width:40%;">
  11. <form name="moose"
  12. action=""
  13. id="moose">
  14.  
  15. <legend>&nbsp;&nbsp;Number
  16. Pronunciator&nbsp;&nbsp;</legend>
  17.  
  18. <div style="padding: 10px;">
  19. <input name="num"
  20. type="text"
  21. value="100"
  22. style=
  23. "font-family:Tahoma;font-size:8pt;width:200px;"
  24. maxlength="315" /> <input type="submit"
  25. value="Say"
  26. style=
  27. "width:80px;font-family:Tahoma;font-size:8pt;" />
  28.  
  29. <div id="output"
  30. style="padding:8px 0 8px 0;">
  31. Inserisci il numero e io proverò a pronunciarlo in
  32. inglese it.
  33. <br />
  34.  
  35. Ricorda: il numero non può contenere più di 303 cifre
  36. </div><a href="http://www.filippocorti.com/"
  37. style="font-size: 7pt;">www.filippocorti.com
  38. WorldWideWeb</a>
  39. </div>
  40. </form>
  41. </div>
  42. </div><script type="text/javascript">
  43. //<![CDATA[
  44. <!-- Begin
  45. /* Eppol.net
  46. http://www.eppol.net */
  47.  
  48. var units=new Array("one","two","three","four","five","six","seven","eight","nine");
  49. var teens=new Array("ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen ","nineteen");
  50. var tens=new Array("twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety");
  51. var illions=new Array('m','b','tr','quadr','quint','sext','sept','oct','non','dec','undec','duodec','tredec','quattuordec','quindec','sexdec','septendec','octodec','novemdec','vigint','unvigint','duovigint','trevigint','quattuorvigint','quinvigint','sexvigint','septenvigint','octovigint','novemvigint','trigint','untrigint','duotrigint','tretrigint','quattuortrigint','quintrigint','sextrigint','septentrigint','octotrigint','novemtrigint','quadragint','unquadragint','duoquadragint','trequadragint','quattuorquadragint','quinquadragint','sexquadragint','septenquadragint','octoquadragint','novemquadragint','quinquagint','unquinquagint','duoquinquagint','trequinquagint','quattuorquinquagint','quinquinquagint','sexquinquagint','septenquinquagint','octoquinquagint','novemquinquagint','sexagint','unsexagint','duosexagint','tresexagint','quattuorsexagint','quinsexagint','sexsexagint','septsexagint','octosexagint','novemsexagint','septuagint','unseptuagint','duoseptuagint','treseptuagint','quattuorseptuagint','quinseptuagint','sexseptuagint','septseptuagint','octoseptuagint','novemseptuagint','octogint','unoctogint','duooctogint','treoctogint','quattuoroctogint','quinoctogint','sexoctogint','septoctogint','octooctogint','novemoctogint','nonagint','unnonagint','duononagint','trenonagint','duattuornonagint','quinnonagint','sexnonagint','septnonagint','octononagint','novemnonagint','cent','cenunt','duocent','centret');
  52. function smallNum(num, mag){
  53. var a=num.charAt(0);
  54. var b=num.charAt(1);
  55. var c=num.charAt(2);
  56. var s="";
  57. if (a!=0) {
  58. s+=units[a-1] + " hundred";
  59. if (b==0 && c==0) return s;
  60. else s+=" and ";
  61. }
  62. if (b==0) {
  63. if (c==0) return "";
  64. return s+units[c-1];
  65. }
  66. if (b==1) {
  67. return s+teens[c];
  68. }
  69. if (b>1) {
  70. s+=tens[b-2];
  71. if (c>0) s+="-" + units[c-1];
  72. return s;
  73. }
  74. }
  75. function fixChars(){
  76. var subject=document.forms.moose.num;
  77. var str=subject.value;
  78. var str2="";
  79. var L=str.length;
  80. var t;
  81. var f=false;
  82. for (var i=0; i<L; i++) {
  83. t=str.charAt(i);
  84. if (t*1==t) {
  85. if (t!=0) f=true;
  86. if (f) str2+=t;
  87. }
  88. }
  89. if (str2=="") str2="0"
  90. subject.value=str2;
  91. }
  92. document.forms.moose.onsubmit=function(){
  93. fixChars();
  94. var s=this.num.value;
  95. if (s.length>315) {
  96. alert("Your number is "+s.length+" digits long.\nThe maximum length is 303 digits.");
  97. return false;
  98. }
  99. var r="", temp="";
  100. while(s.length%3>0)s="0"+s;
  101. var max=Math.ceil(s.length/3);
  102. for (var i=0; i<max; i++) {
  103. temp=smallNum(s.substr(i*3, 3));
  104. if (temp!="") {
  105. if (max-i==1 && r!="" && s.substr(i*3, 3)<100) r+=" and ";
  106. else if (r!="") r+=", ";
  107. if (max-i==2) temp+=" thousand";
  108. if (max-i>2) temp+=" "+illions[max-i-3]+"illion";
  109. }
  110. r+=temp;
  111. }
  112. if (s==0) r="zero";
  113. r=r.charAt(0).toUpperCase()+r.substring(1,r.length)+".";
  114. document.getElementById("output").innerHTML=r;
  115. return false;
  116. }
  117. // End -->
  118. //]]>
  119.  
  120.  
  121. <font face="arial, helvetica">Sai leggere i numeri?
  122. <br />
  123. by <a href="www.filippocorti.com">Eppol</a></font>
  124. </center>
  125.  
  126. <p></p>
  127. </body>
  128. </html>

URL: http://www.filippocorti.com/service/numeri_in_inglese/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.