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>

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。