/ Published in: HTML
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> </head> <body> <div align="center"> <div style= "text-align=center;font-family:Tahoma;font-size:8pt;width:40%;"> <form name="moose" action="" id="moose"> <fieldset> <legend> Number Pronunciator </legend> <div style="padding: 10px;"> <input name="num" type="text" value="100" style= "font-family:Tahoma;font-size:8pt;width:200px;" maxlength="315" /> <input type="submit" value="Say" style= "width:80px;font-family:Tahoma;font-size:8pt;" /> <div id="output" style="padding:8px 0 8px 0;"> Inserisci il numero e io proverò a pronunciarlo in inglese it. <br /> Ricorda: il numero non può contenere più di 303 cifre style="font-size: 7pt;">www.filippocorti.com WorldWideWeb</a> </div> </fieldset> </form> </div> //<![CDATA[ <!-- Begin /* Eppol.net http://www.eppol.net */ var units=new Array("one","two","three","four","five","six","seven","eight","nine"); var teens=new Array("ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen ","nineteen"); var tens=new Array("twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"); 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'); function smallNum(num, mag){ var a=num.charAt(0); var b=num.charAt(1); var c=num.charAt(2); var s=""; if (a!=0) { s+=units[a-1] + " hundred"; if (b==0 && c==0) return s; else s+=" and "; } if (b==0) { if (c==0) return ""; return s+units[c-1]; } if (b==1) { return s+teens[c]; } if (b>1) { s+=tens[b-2]; if (c>0) s+="-" + units[c-1]; return s; } } function fixChars(){ var subject=document.forms.moose.num; var str=subject.value; var str2=""; var L=str.length; var t; var f=false; for (var i=0; i<L; i++) { t=str.charAt(i); if (t*1==t) { if (t!=0) f=true; if (f) str2+=t; } } if (str2=="") str2="0" subject.value=str2; } document.forms.moose.onsubmit=function(){ fixChars(); var s=this.num.value; if (s.length>315) { alert("Your number is "+s.length+" digits long.\nThe maximum length is 303 digits."); return false; } var r="", temp=""; while(s.length%3>0)s="0"+s; var max=Math.ceil(s.length/3); for (var i=0; i<max; i++) { temp=smallNum(s.substr(i*3, 3)); if (temp!="") { if (max-i==1 && r!="" && s.substr(i*3, 3)<100) r+=" and "; else if (r!="") r+=", "; if (max-i==2) temp+=" thousand"; if (max-i>2) temp+=" "+illions[max-i-3]+"illion"; } r+=temp; } if (s==0) r="zero"; r=r.charAt(0).toUpperCase()+r.substring(1,r.length)+"."; document.getElementById("output").innerHTML=r; return false; } // End --> //]]> </script> <center> <font face="arial, helvetica">Sai leggere i numeri? <br /> </center> </body> </html>
URL: http://www.filippocorti.com/service/numeri_in_inglese/