<script language="javascript" type="text/javascript"> function convert_to_roman(val) { var roman_numerals=['I', 'IV', 'V', 'IX', 'X', 'XL', 'L', 'XC', 'C', 'CD', 'D', 'CM', 'M']; var list_numbers=[1, 4, 5, 9, 10, 40, 50, 90, 100, 400, 500, 900, 1000]; var x = parseInt(val); if( x<1 || x>4999 ) { alert(x+' number is out of range.'); return 0; } display_result = ''; for(a=12; a>=0;) if( list_numbers[a]<=x ) { display_result += roman_numerals[a]; x -= list_numbers[a]; } else { a--; } return(display_result); } $(document).ready(function () { value_number = parseInt(prompt("Enter a Decimal Number to Convert into Roman Numeral")); document.write("<h3 style='text-align:center; margin-top: 100px;'><b style='color:blue;'>"+value_number + "</b> is equivalent to <b style='color:red;'>" + convert_to_roman(value_number) + "</b> in roman numerals. </h3>"); }); </script>