JavaScript used to convert given numeric values to roman numerals. Simply enter a number in the appropriate space below and click on the Convert button.
<!-- Script by hscripts.com -->
<!-- More scripts @www.hscripts.com -->
<style type="text/css">
.txt{border:1px solid grey;width:150px;height:25px;font-size:12px;padding:5px;}
.fnt{font-size:12px;font-family:arial,verdana;}
</style>
<script type="text/javascript">
function convert_roman()
{var narr=new Array("1000000","900000","500000","400000","100000","90000","50000","40000","10000","9000","5000","4000","1000","900","500","400","100","90","50","40","10","9","5","4","1");var rarr=new Array("<span style='text-decoration: overline'>M</span>","<span style='text-decoration: overline'>CM</span>","<span style='text-decoration: overline'>D</span>","<span style='text-decoration: overline'>CD</span>","<span style='text-decoration: overline'>C</span>", "<span style='text-decoration: overline'>XC</span>","<span style='text-decoration: overline'>L</span>","<span style='text-decoration: overline'>XL</span>","<span style='text-decoration: overline'>X</span>","<span style='text-decoration: overline'>IX</span>","<span style='text-decoration: overline'>V</span>","<span style='text-decoration: overline'>IV</span>","M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I");var num = parseInt(document.getElementById("num").value);if(num > 3999999 || num < 1){alert("Please enter a number between 1 and 3,999,999");return;}var result = "";var chk = num;while (chk > 0 ){var i;for (i=0; i<narr.length; i++){if(chk >= narr[i] ){result += rarr[i];chk -= narr[i];break;}}}document.getElementById("res").innerHTML=result;
}
function isinteger(s)
{var i;s = s.toString();for (i = 0; i < s.length; i++){var c = s.charAt(i);if (isNaN(c)) {alert("Given value is not a number");return false;}}return true;
}
</script>
<!-- Script by hscripts.com -->