I am creating a program using css, html, and javascript. It must convert numbers to roman numerals. I can't figure out why I just don't get any output. Please help!
Javascript
htmlCode:function convert(d) { document.getElementById("output").innerText = value; if (!+d){ alert('No data was input'); return ''; var digits = String(+d).split(""); key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM", "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC", "","I","II","III","IV","V","VI","VII","VIII","IX"]; roman = ""; i = 3; while (i--) roman = (key[+digits.pop() + (i * 10)] || "") + roman; return Array(+digits.join("") + 1).join("M") + roman; }
Code:.....other code above <body> <div id="box"> <form> <p> CSE 3420.001<br/> Program 3 - Javascript Application<br/> Don Retzlaff donr@unt.edu </p> <input type="text" name="digit" id = "nums" value=""/> <!-- <input type="submit" name="button" value="Convert to Roman Numerals" --> <button onclick="convert(d)">convert to Roman Numerals</button> </form> <span id="output"></span> </div> </body> .......other code below
Thanks!


Reply With Quote

Bookmarks