• javascript 数字如何转换成中文大写


     


    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>天路行互联网商品交易所 - - 退款单</title>
    <meta http-equiv="pragma" content="no-cache">
    <style type="text/css">
    table{border-collapse:collapse;border: 0 0 0 0; border-bottom-color:#000000; border-color:#000000}
    td{font-family: "宋体", "楷体_GB2312", "黑体",Arial,Helvetica, sans-serif;color:#000000;font-size: 13px;}
    th{font-family: "宋体", "楷体_GB2312", "黑体",Arial,Helvetica, sans-serif;color:#000000;font-size: 13px;}
    </style>
    <script type="text/javascript" language="javascript">
    <!--//
    function Arabia_to_Chinese(Num)
    {
     for(i=Num.length-1;i>=0;i--)
     {
      Num = Num.replace(",","")//替换tomoney()中的“,”
      Num = Num.replace(" ","")//替换tomoney()中的空格
     }
     Num = Num.replace("¥","")//替换掉可能出现的¥字符
     if(isNaN(Num))
     { //验证输入的字符是否为数字
      alert("请检查小写金额是否正确");
      return;
     }
     //---字符处理完毕,开始转换,转换采用前后两部分分别转换---//
     part = String(Num).split(".");
     newchar = "";
     //小数点前进行转化
     for(i=part[0].length-1;i>=0;i--)
     {
      if(part[0].length > 10)
      {
       alert("位数过大,无法计算");
       return "";
      }//若数量超过拾亿单位,提示
      tmpnewchar = ""
      perchar = part[0].charAt(i);
      switch(perchar)
      {
       case "0": tmpnewchar="零" + tmpnewchar ;break;
       case "1": tmpnewchar="壹" + tmpnewchar ;break;
       case "2": tmpnewchar="贰" + tmpnewchar ;break;
       case "3": tmpnewchar="叁" + tmpnewchar ;break;
       case "4": tmpnewchar="肆" + tmpnewchar ;break;
       case "5": tmpnewchar="伍" + tmpnewchar ;break;
       case "6": tmpnewchar="陆" + tmpnewchar ;break;
       case "7": tmpnewchar="柒" + tmpnewchar ;break;
       case "8": tmpnewchar="捌" + tmpnewchar ;break;
       case "9": tmpnewchar="玖" + tmpnewchar ;break;
      }
      switch(part[0].length-i-1)
      {
       case 0: tmpnewchar = tmpnewchar +"元" ;break;
       case 1: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break;
       case 2: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break;
       case 3: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break;
       case 4: tmpnewchar= tmpnewchar +"万" ;break;
       case 5: if(perchar!=0)tmpnewchar= tmpnewchar +"拾" ;break;
       case 6: if(perchar!=0)tmpnewchar= tmpnewchar +"佰" ;break;
       case 7: if(perchar!=0)tmpnewchar= tmpnewchar +"仟" ;break;
       case 8: tmpnewchar= tmpnewchar +"亿" ;break;
       case 9: tmpnewchar= tmpnewchar +"拾" ;break;
      }
      newchar = tmpnewchar + newchar;
     }
     //小数点之后进行转化
     if(Num.indexOf(".")!=-1)
     {
      if(part[1].length > 2)
      {
       alert("小数点之后只能保留两位,系统将自动截段");
       part[1] = part[1].substr(0,2)
      }
      for(i=0;i<part[1].length;i++)
      {
       tmpnewchar = ""
       perchar = part[1].charAt(i)
       switch(perchar)
       {
        case "0": tmpnewchar="零" + tmpnewchar ;break;
        case "1": tmpnewchar="壹" + tmpnewchar ;break;
        case "2": tmpnewchar="贰" + tmpnewchar ;break;
        case "3": tmpnewchar="叁" + tmpnewchar ;break;
        case "4": tmpnewchar="肆" + tmpnewchar ;break;
        case "5": tmpnewchar="伍" + tmpnewchar ;break;
        case "6": tmpnewchar="陆" + tmpnewchar ;break;
        case "7": tmpnewchar="柒" + tmpnewchar ;break;
        case "8": tmpnewchar="捌" + tmpnewchar ;break;
        case "9": tmpnewchar="玖" + tmpnewchar ;break;
          }
       if(i==0)tmpnewchar =tmpnewchar + "角";
       if(i==1)tmpnewchar = tmpnewchar + "分";
       newchar = newchar + tmpnewchar;
      }
     }
     //替换所有无用汉字
     while(newchar.search("零零") != -1)
      newchar = newchar.replace("零零", "零");
     newchar = newchar.replace("零亿", "亿");
     newchar = newchar.replace("亿万", "亿");
     newchar = newchar.replace("零万", "万");
     newchar = newchar.replace("零元", "元");
     newchar = newchar.replace("零角", "");
     newchar = newchar.replace("零分", "");

     if (newchar.charAt(newchar.length-1) == "元" || newchar.charAt(newchar.length-1) == "角")
         newchar = newchar+"整"
     return newchar;
    }
    function printp(obj)
    {
      if (obj.style.display=="none")
      {
       obj.style.display="";
      }
      else
      {
       obj.style.display="none";
      }
    }
    //-->
    </script>
    </head>
    <body style="text-align:left; vertical-align:top;">
    <table border="0" cellpadding="1" cellspacing="1" style="238px;">
     <tr>
      <td align="center">
       
      <table border="0" cellpadding="0" cellspacing="0" style="100%;">
       <tr>
        <td align="center" valign="middle">
            <table border="0" width="100%">
                <tr>
                    <td><h4 style="vertical-align:middle;"><img src="images/2.gif" alt="Logo" style="border:0px; vertical-align:middle;" width="72" height="30" /><b>中关村网络购物吧</b></h4></td>
                </tr>
            </table>
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tr>
           <td align="left" colspan="2"><b>地址:</b>北京市海淀区中关村科学院南路19号</td>
          </tr>
          <tr>
           <td align="left" style="50%"><b>邮编:</b>100080</td>
           <td align="right" style="vertical-align:top;"><b>电话:</b>82523518</td>
          </tr>
         </table>
        </td>
       </tr>
       <tr>
        <td align="center">
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
             <tr>
           <td align="left" colspan="2"><b>订单号:</b>00812101152200695</td>
          </tr>
          <tr>
           <td align="left" colspan="2"><b>退款日期:</b>2008年12月11日 9:00:35</td>
          </tr>
          <tr>
           <td align="left">
            <b>退款方式:</b>
            现金
           </td>
           <td align="right"></td>
          </tr>
         </table>
        </td>
       </tr>
       <tr>
        <td align="center">
         <table border="0" cellpadding="0" cellspacing="0" style="100%;">
          <tr>
           <td align="left"><b>订货人:</b>赵英俊</td>
           <td align="left"><b>电话:</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
          </tr>
          <tr>
           <td align="left" colspan="2"><b>
             地址:</b>北京市宣武区&nbsp;&nbsp;&nbsp;&nbsp;
             <br><b>退款原因:</b></td>
          </tr>
         </table>
        </td>
       </tr>
       <tr>
        <td align="center">
         <table border="1" cellpadding="2" cellspacing="0" width="100%" bordercolor="#000000" class="table">
          <tr style="height:20px;">
           <th style="10%;"><b>编号</b></th>
           <th><b>商品名称</b></th>
           <th style="10%;"><b>数量</b></th>
           <th style="10%;"><b>总价</b></th>
          </tr>
          <tr style="height:20px;">
           <td align="center">7625</td>
           <td align="center">春兰空调1.5匹机型</td>
           <td align="center">1</td>
           <td align="center">2,030.00</td>
          </tr>
          <tr style="height:20px;">
           <td></td>
           <td></td>
           <td></td>
           <td></td>
          </tr>
         </table>
        </td>
       </tr>
       <tr>
        <td align="center">
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tr>
           <td align="left"><b>合 计(数量):</b>1</td>
           <td align="right"><b>(小写):</b>2,060.00元</td>
          </tr>
          <tr>
           <td align="left" colspan="2"><b>退款总额(大写):</b><script language="javascript">document.write(Arabia_to_Chinese("2,060.00"));</script></td>
          </tr>
         </table>
        </td>
       </tr>
       <tr>
        <td align="center">
        </td>
       </tr>
       <tr>
        <td align="center" valign="top">
         <table border="0" cellpadding="0" cellspacing="0" width="100%">
          <tr>
           <td align="left"><b>业务员:</b>店面&nbsp;&nbsp;<b>收银员:</b>Admin</td>
           <td align="left"></td>
          </tr>
          <tr>
           <td align="left"><b>签收日期:</b>&nbsp;&nbsp;&nbsp;&nbsp;年&nbsp;&nbsp;月&nbsp;&nbsp;日</td>
          </tr>
          <tr>
              <td align="left"><b>顾客签收:</b>&nbsp;&nbsp;&nbsp;&nbsp;</td>
           <td align="left"><span style="font-size:16px;">盖章:</span>&nbsp;&nbsp;</td>
           <td></td>
          </tr>
         </table>
        </td>
       </tr>
       <tr style="height:20px;">
        <td align="right" colspan="2" style="font-size:12px;">天路行网络科技(北京)有限公司监制</td>
       </tr>
             <tr>
              <td align="center" colspan="2"><hr /></td>
             </tr>
      </table>

      </td>
     </tr>
     <tr>
      <td align="center">
       <center id="printbar"><button onClick="printp(printbar);print();printp(printbar);" id="button1">打 印</button></center>
      </td>
     </tr>
    </table>
    </body>
    </html>

  • 相关阅读:
    Eclipse快捷键大全(转载)
    IE9浏览Flash页面时显示错位并不停地闪烁
    flash全屏事件和键盘按下事件部分不能触发问题
    AS3摘要(转载)
    【as3手册小记】ActionScript 中处理全屏模式的注意事项
    巧用FlashPaper 让Word文档变Flash
    AS3视频照相截图(转载)
    Json串到json对象的转换
    映射文件详解(转)
    Jquery .ajax方法分析(一)
  • 原文地址:https://www.cnblogs.com/jiangchongwei/p/1352426.html
Copyright © 2020-2023  润新知