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>

版权声明:本文博主原创文章,博客,未经同意不得转载。

posted @ 2015-09-15 08:57  hrhguanli  阅读(204)  评论(0编辑  收藏  举报