<!-- 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;font-family:arial,verdana;}
.fnt{font-size:12px;font-family:arial,verdana;}
</style>
<script type="text/javascript">
var rarr = new Array("M",
"CM", "D", "CD", "CCC", "CC", "C", "XC", "L", "XL", "XXX", "XX", "X", "IX", "V", "IV", "III", "II", "I");var narr = new Array(1000,900,500,400,300,200,100,90,50,40,30,20,10,9,5,4,3,2,1); var warr = new Array("CMCM",
"CMD",
"CMCD", "CMC", "DD", "DCD", "CDCD", "CDC", "CCCC", "XCXC",
"XCL", "XCXL", "XCX", "LL", "LXL", "XLXL", "XLX", "XXXX", "IXIX",
"IXV", "IXIV", "IXI", "IVIV", "IVI", "IIII");var carr= new Array("MDCCC", "MCD",
"MIII", "M",
"M",
"CM",
"DCCC", "D",
"CD",
"CLXXX", "CXL", "CIII", "C",
"C",
"XC",
"LXXX", "L",
"XL",
"XVIII", "XIV", "XIII", "X",
"VIII", "V",
"IV");
function convert_numeric()
{var rom = document.getElementById("roman").value;var roman = rom.replace(/ /g, "");roman = roman.toUpperCase();roman = roman.replace(/[^IVXLCDM]/g, "");document.getElementById("roman").value=roman;if (roman.length == 0){document.getElementById("res").innerHTML = "";return;}var position = 0;var result = 0;var pp = -1;while(position < roman.length){var p = getnextletter(roman, position);if (pp != 0){if ( narr[pp] < narr[p] ){document.getElementById("res").innerHTML = "Error. "+rarr[p]+" should not follow "+rarr[pp];return;}}if(p < 0)return;position += rarr[p].length;result += narr[p];pp = p;}document.getElementById("res").innerHTML =
result;
}
function getnextletter(roman, position)
{for (i=0; i<warr.length; i++){if ( roman.indexOf(warr[i], position) == position ){document.getElementById("res").innerHTML = warr[i] + " is not correct replace with " + carr[i] + ".";return -1;}}for (i=0; i<rarr.length; i++){if ( roman.indexOf(rarr[i], position) == position)return i;}document.getElementById("res").innerHTML = "invalid at " +position;return -1;
}
</script><!-- Script by hscripts.com -->