Phiên bản đầy đủ: jsB@nk » Tính toán » Đổi sang số La Mã
URL: https://www.javascriptbank.com/roman-converter.html
Một đoạn mã JavaScript JavaScript khác để tạo hiệu ứng đổi một số dạng thập phân sang số La Mã.
Phiên bản đầy đủ: jsB@nk » Tính toán » Đổi sang số La Mã
URL: https://www.javascriptbank.com/roman-converter.html
<script>function romanise(){var persian=numeral.value;var roman="";var ronumdashes="";var buffer=10-persian.length;while (buffer>0) {persian="0"+persian;buffer--}var units=new Array("","I","II","III","IV","V","VI","VII","VIII","IX");var tens=new Array("","X","XX","XXX","XL","L","LX","LXX","LXXX","XC");var hundreds=newArray("","C","CC","CCC","CD","D","DC","DCC","DCCC","CM");var thousands=newArray("","M","MM","MMM","MV","V","VM","VMM","VMMM","MX");var billionsdashes=newArray("","=","==","===","=≡","≡","≡=","≡==","≡===","=≡");romandashes=billionsdashes[persian.substring(0,1)];var hundredmillionsdashes=newArray("","=","==","===","==","=","==","===","====","==");romandashes+=hundredmillionsdashes[persian.substring(1,2)];var tenmillionsdashes=newArray("","=","==","===","==","=","==","===","====","==");romandashes+=tenmillionsdashes[persian.substring(2,3)];var millionsdashes=newArray("","_","__","___","_=","=","=_","=__","=___","_=");romandashes+=millionsdashes[persian.substring(3,4)];var hundredthousandsdashes=newArray("","_","__","___","__","_","__","___","____","__");romandashes+=hundredthousandsdashes[persian.substring(4,5)];var tenthousandsdashes=newArray("","_","__","___","__","_","__","___","____","__");romandashes+=tenthousandsdashes[persian.substring(5,6)];var thousandsdashes=newArray("","","",""," _","_","_","_","_"," _");romandashes+=thousandsdashes[persian.substring(6,7)];roman=thousands[persian.substring(0,1)];roman+=hundreds[persian.substring(1,2)];roman+=tens[persian.substring(2,3)];roman+=thousands[persian.substring(3,4)];roman+=hundreds[persian.substring(4,5)];roman+=tens[persian.substring(5,6)];roman+=thousands[persian.substring(6,7)];roman+=hundreds[persian.substring(7,8)];roman+=tens[persian.substring(8,9)];roman+=units[persian.substring(9,10)];result.innerHTML=romandashes+"<br>"+roman;}</script><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<input type="text" name=numeral size="10" onKeypress="if(event.keyCode<48 || event.keyCode>57) event.returnValue=false;" maxlength="10"><input type="button" value="Convert" onclick="romanise()"><br><tt id=result style=font-size:14pt></tt><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->