Input Number:
Source code:
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en"> <HTML xmlns = "http://www.w3.org/1999/xhtml"> <body> <div> input number: <input id = "txtnum" type = "text" onkeyup = "shownum ();" value = "856"/> <Div id = "divnum" style = "height: 20px; position: relative; margin-top: 5px; "> </div> <SCRIPT type =" text/JavaScript "> function shownum () {var txtnum = document. getelementbyid ('txtnum'); var divnum = document. getelementbyid ('divnum'); If (isnan (txtnum. value) {return;} divnum. innerhtml = ''; var width = math. floor (divnum. offsetheight/5); For (VAR I = 0; I <txtnum. value. length; I ++) {var Index = parseint (txtnum. value [I]); var strnum = arrnum [Index]; for (VAR J = 0; j <strnum. length; j ++) {If (strnum [J] = '1') {var DIV = getdiv (width); Div. style. left = J % 3 * width + I * width * 4; Div. style. top = math. floor (J/3) * width; divnum. appendchild (DIV) ;}}} var arrnum = ['000000', '000000', '000000', '000000', '000000', '000000 ', '20140901', '20160901', '20160901', '20160901']; function getdiv (width) {var DIV = document. createelement ('div '); Div. style. width = width; Div. style. height = width; Div. style. backgroundcolor = 'red'; Div. style. position = 'absolute '; return div;} shownum (); </SCRIPT> </div> </form> </body>