js实现一个人民币小写金额转成大写金额的代码
代码语言:html
所属分类:其他
代码描述:js实现一个人民币小写金额转成大写金额的代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <style> body { background: white; } h1 { font: 32px "微软雅黑","Microsoft YaHei"; color: #333; margin-bottom: 6px; text-align: center; } .title { width: 100%; border: 0; padding: 4px 0; } .title .zuozhe { color: #AAA } .title span { float: right; margin-top: -40px } .title a { color: #390; padding: 4px } /* 文本域 */ .tooltext { padding: 4px; margin: 10px 0; font-size: 16px; color: #333 } .toolarea { padding: 4px; margin: 8px 0; width: 100%; height: 250px; color: #333; display: block } /* 按钮 */ .bt-green { font-size: 14px; border: none; line-height: 33px; background: #6FB934; font-weight: bold; color: #FFF; cursor: pointer; padding: 0 18px; margin-right: 12px } .bt-green:hover { background: #5FA924; text-decoration: none } .toolcode { margin: 0 8px 26px } hr { border: 0; } </style> </head> <body> <div class="toolcode"> <p class="alert alert-info"> 转换方法:输入人民币金额的小写阿拉伯数字,例如1688.99,然后点击“转换为大写金额”按钮即可得转换成汉字。在输入数字的时候,可以包含小数点,也可以写成千进制,例如1,688.99(注意是英文逗号,而不是中文逗号)。 </p> <p> 小写金额(¥):<br> <input name="Digits" class="tooltext" id="Digits" value="1,688.99" size="40" type="text"> <input id="Convert" class="bt-green" value="转换为大写金额" name="Convert" onclick="Result.value = convertCurrency(Digits.value);" type="button"> </p> <div style="clear:both"></div> <p> 大写金额: <textarea name="Result" type="text" class="toolarea" style="color:#333;font-size:28px;height:36px" id="Result"></textarea> </p> <p class="alert alert-success"> 人民币金额用到的中文大写汉字如下:<br> <strong>零、壹、贰、叁、肆、伍、陆、柒、捌、玖、拾、佰、仟、万、亿。 </strong> </p> </div> <script type="text/javascript" charset="utf-8"> function convertCurrency(currencyDigits) { // Constants: var MAXIMUM_NUMBER = 99999999999.99; // Predefine the radix characters and currency symbols for output: var CN_ZERO = "零"; var CN_ONE = "壹"; var CN_TWO = "贰"; var CN_THREE = "叁"; var CN_FOUR = "肆"; var CN_FIVE = "伍"; var CN_SIX = "陆"; var CN_SEVEN = "柒"; var CN_EIGHT = "捌"; var CN_NINE = "玖"; var CN_TEN = "拾"; var CN_HUNDRED = "佰"; var CN_THOUSAND = "仟"; var CN_TEN_THOUSAND = "万"; var CN_HUNDRED_MILLION = "亿"; var CN_SYMBOL = "人民币"; var CN_DOLLAR = "元"; var CN_TEN_CENT = "角"; var CN_CENT = "分"; var CN_INTEGER = "整"; // Variables: var integral; // Represent integral part of digit number. var decimal; // Represent decimal part of digit number. var outputCharacters; // The output result. var parts; var digits, radices, bigRadices, decimals; var zeroCount; var i, p, d; var quotient, modulus; // Validate.........完整代码请登录后点击上方下载按钮下载查看
网友评论0