js实现小写转大写,js实现数字转人民币
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>小写转大写</title> <style type="text/css"> div { position:absolute;left:lin;top:lin;bottom:lin;right:lin; background-color:#AE57A4; text-align:center; width:500px;} </style> <script type="text/javascript"> function transformNumber() { var nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; var chins = ["零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"]; var money = ["元", "十", "百", "千", "万", "十", "百", "千", "亿", "", "", ""]; var money1 = ["角", "分"]; var number = document.getElementById("number").value; var numbers = number.split(".") var chin = ""; var chin1 = ""; for (var i = numbers[0].length; i > 0; i--) { var s = numbers[0].charAt(numbers[0].length - i); chin += chins[s] + money[i - 1]; } if (numbers[1] != null) { for (var j = 0; j < numbers[1].length; j++) { var b = numbers[1].charAt(j); chin1 += chins[b] + money1[j]; } } var china = chin + chin1; document.getElementById("newnumber").value = china; } function clearnumber() { document.getElementById("number").value = ""; document.getElementById("newnumber").value = ""; } function promptMessage() { document.getElementById("number").value = "小数点后保留两位小数"; } function clearMessage() { document.getElementById("number").value = ""; } window.onload = promptMessage; </script> </head> <body> <div><br/><br/> <h3>银行钱款转换器</h3><br/><br/><br/><br/> <span>请输入需转换金额:</span><input type="text" id="number" onfocus="clearMessage();"><br/><br/> <span>转换后的大写金额:</span><input type="text" id="newnumber"/><br/><br/> <input type="button" id="transform" value="转换" onclick="transformNumber();" /> <input type="button" id="clear" value="清零" onclick="clearnumber();"> </div> </body> </html>
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!