表单自动计算问题

销售开单
 
单据编号:
 
客户名称:
    
收款方式:
  请选择收款方式
仓库:
  请选择仓库
备注:
 
序号
货品编码
货品名称
数量
单价
金额
1
2
3
4
5
6
7
8
9
10
合计人民币大写:


< html >
< head >
< meta  http-equiv ="Content-Type"  content ="text/html; charset=gb2312" >
< title > 销售单据金额计算—合计—转大写 </ title >
< style  type ="text/css" >
<!--
  .DoubleColorTable tr
{}{background-color:expression(rowIndex%2==0?'#FCF5DA':'#FFFFFF');
  font-size
: 12px;
  
}

-->
</ style >
< link  href ="cc.css"  rel ="stylesheet"  type ="text/css" >
< SCRIPT  language =JavaScript >
function $(o){return document.getElementById(o)}
window.onload
=function init(){
var input_obj=$("amount_price_total").getElementsByTagName("input"),j=input_obj.length;
for(var i=0;i<j;i++){
    
if (input_obj[i].id.indexOf("price")!=-1)input_obj[i].onblur=function(){calculate(this.id);calculate_total();}
}

}

function calculate(id){//金额
    var numlen=id.substring(5,id.length)
    
var v_amount=$("amount"+numlen).value
    
var v_price=$(id).value
    
if (v_amount>0&&v_price>0){
        $(
"total"+numlen).value=Math.ceil(v_amount*v_price*1000)/1000;//保留三位
        $("amount"+numlen).onblur=function(){calculate(id);calculate_total();}
    }

    
else if (v_amount==""||v_price==""){
        $(
"amount"+numlen).value=""
        $(id).value
=""
        $(
"total"+numlen).value=""
    }

    
else {
        $(
"total"+numlen).value="非法输入"
    }

}

function calculate_total(){//合计
var temp_total=0+1-1;
var input_obj=$("amount_price_total").getElementsByTagName("input"),j=input_obj.length;
for(var i=0;i<j;i++){
    
if (input_obj[i].id.indexOf("total")!=-1 && input_obj[i].value>0){
        
var numlen=input_obj[i].id.substring(5,input_obj[i].id.length)
        
var v_amount=$("amount"+numlen).value
        
var v_price=$("price"+numlen).value
        temp_total
+=v_amount*v_price
    }

}

temp_total
=Math.ceil(temp_total*100)/100;//保留二位
$("tt").innerHTML="("+temp_total+"元) ¥"+bigwrite(temp_total)
}

function bigwrite(x){//转换大写
var caiying2007_bp=["","","","","","","","","亿","","","",""];//最高位为"万亿",不够用时可依律增加
var caiying2007_ap=["","分正"]
var caiying2007_s=["","","","","","","","","",""]
//获取整数并转换大写
if (x>=1){//金额不小于1元
    var caiying2007_b=x.toString().split(".")[0].split(""),k=caiying2007_b.length
    
//个位以前
    for (var i=0;i<k-1;i++){
        
if ((k-i)==9 && parseInt(caiying2007_b[i])==0){//亿
            caiying2007_b[i]=caiying2007_bp[k-i-1];
        }

        
if ((k-i)==5 && parseInt(caiying2007_b[i])==0){//
            var poo=false
            
for (var p2=1;p2<4;p2++){
                
if (parseInt(caiying2007_b[i-p2])!=0){poo=true;p2=100}
            }

            caiying2007_b[i]
=(poo)?caiying2007_bp[k-i-1]:"";
        }

    }

    
for (var i=0;i<k-1;i++){
        
if (parseInt(caiying2007_b[i])==0)caiying2007_b[i]=(caiying2007_b[i-1]=="" ||caiying2007_b[i-1]=="")?"":"";
else caiying2007_b[i]=(caiying2007_b[i]=="")?"":(caiying2007_b[i]=="亿")?"亿":(caiying2007_b[i]=="")?"":(caiying2007_b[i]=="")?"":caiying2007_s[parseInt(caiying2007_b[i])]+caiying2007_bp[k-i-1]
    }

    
    
//个位
    caiying2007_b[k-1]=(parseInt(caiying2007_b[k-1])==0)?caiying2007_bp[0]:caiying2007_s[parseInt(caiying2007_b[k-1])]+caiying2007_bp[0]
    caiying2007_b_
=caiying2007_b.join("")
//去无效"零",如要求保留"零亿"/"零万"/"零元",屏蔽或删除下面三句
    caiying2007_b_=caiying2007_b_.replace("零万","")
    caiying2007_b_
=caiying2007_b_.replace("零亿","亿")
    caiying2007_b_
=caiying2007_b_.replace("零元","")
}

//金额不小于1元
//
else caiying2007_b_="零元"//金额小于1元显示"零元"
else caiying2007_b_="";//金额小于1元不显示"零元"
//
获取小数并转换大写
if (x.toString().split(".")[1]){
var caiying2007_a=x.toString().split(".")[1].split("")
    
//caiying2007_a[0]=caiying2007_s[parseInt(caiying2007_a[0])]+caiying2007_ap[0];//显示“零角”
    caiying2007_a[0]=(parseInt(caiying2007_a[0])==0)?"":caiying2007_s[parseInt(caiying2007_a[0])]+caiying2007_ap[0];//不显示“零角”
    if (caiying2007_a[1])caiying2007_a[1]=(parseInt(caiying2007_a[1])==0)?caiying2007_ap[1]:caiying2007_s[parseInt(caiying2007_a[1])]+caiying2007_ap[1]
    
else caiying2007_a[1]=""
caiying2007_a_
=caiying2007_a.join("")
}

else caiying2007_a_=""
//合并整数小数
var caiying2007=caiying2007_b_+caiying2007_a_
return caiying2007
}

</ SCRIPT >  
</ head >
< body >
< table  width ="100%"  height ="100%"   border ="0"  cellpadding ="0"  cellspacing ="0" >
  
< tr >
    
< td  align ="center"  valign ="middle" >< table  width ="724"  border ="1"  cellpadding ="0"  cellspacing ="1"  bordercolor ="#CCCCCC"  style ="border-collapse: collapse" >
      
< tr  bgcolor ="#F0F0F0" >
        
< td  colspan ="2" >< table  width ="718" >
            
< tr >
              
< td >< table  width ="100%"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                  
< tr >
                    
< td  height ="40" >< div  align ="center"  class ="S_bt" > 销售开单 </ div ></ td >
                  
</ tr >
                  
< tr >
                    
< td >< div  align ="center" >
                        
< table  width ="400"  height ="1"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                          
< tr >
                            
< td  bgcolor ="#666666" ></ td >
                          
</ tr >
                        
</ table >
                    
</ div ></ td >
                  
</ tr >
              
</ table ></ td >
            
</ tr >
            
< tr >
              
< td >< table  width ="100%"   border ="0"  cellspacing ="0"  cellpadding ="0" >
                  
< tr >
                    
< td >   </ td >
                  
</ tr >
                
</ table >
                  
< table  width ="100%"  border ="0"  cellpadding ="0"  cellspacing ="0" >
                    
< tr >
                      
< td  colspan ="4" >< table  width ="100%"   border ="0"  cellpadding ="0"  cellspacing ="0"  class ="texts" >
                          
< tr >
                            
< td >< div  align ="right" > 单据编号: </ div ></ td >
                            
< td  width ="200" > &nbsp;
                                
< input  name ="textfield22"  type ="text"  class ="S_input"  size ="20" ></ td >
                          
</ tr >
                      
</ table ></ td >
                    
</ tr >
                    
< tr >
                      
< td  colspan ="4" >< table  width ="710"  height ="80"   border ="0"  cellpadding ="0"  cellspacing ="0"  class ="texts" >
                          
< tr >
                            
< td  width ="80" >< div  align ="right" > 客户名称: </ div ></ td >
                            
< td  width ="317" > &nbsp;
                                
< input  name ="textfield2"  type ="text"  class ="S_input"  size ="35" ></ td >
                            
< td  width ="113" >   </ td >
                            
< td  width ="200" >   </ td >
                          
</ tr >
                          
< tr >
                            
< td >< div  align ="right" > 收款方式: </ div ></ td >
                            
< td > &nbsp;
                                
< select  name ="select2"  class ="S_input" >
                                  
< option  selected > 请选择收款方式 </ option >
                              
</ select ></ td >
                            
< td >< div  align ="right" > 仓库: </ div ></ td >
                            
< td > &nbsp;
                                
< select  name ="select"  class ="S_input" >
                                  
< option  selected > 请选择仓库 </ option >
                              
</ select ></ td >
                          
</ tr >
                          
< tr >
                            
< td >< div  align ="right" > 备注: </ div ></ td >
                            
< td  colspan ="3" > &nbsp;
                                
< input  name ="textfield"  type ="text"  class ="S_input"  size ="70" ></ td >
                          
</ tr >
                      
</ table ></ td >
                    
</ tr >
                
</ table ></ td >
            
</ tr >
        
</ table ></ td >
      
</ tr >
    
</ table >
      
< table  width ="724"  border ="0"  cellpadding ="0"  cellspacing ="0"  style ="border-collapse: collapse" >
        
< tr >
          
< td  colspan ="2" >< form  name ="form1" >< table  width ="724"  border ="1"  cellpadding ="0"  cellspacing ="1"  bordercolor ="#CCCCCC"  style ="border-collapse: collapse"  class ="texts" >
              
< tr  bgcolor ="#F8ECB4" >
                
< td  width ="30"  height ="20" >< div  align ="center" >< strong > 序号 </ strong ></ div ></ td >
                
< td  width ="187" >< div  align ="center" >< strong > 货品编码 </ strong ></ div ></ td >
                
< td  width ="187" >< div  align ="center" >< strong > 货品名称 </ strong ></ div ></ td >
                
< td  width ="97" >< div  align ="center" >< strong > 数量 </ strong ></ div ></ td >
                
< td  width ="97" >< div  align ="center" >< strong > 单价 </ strong ></ div ></ td >
                
< td  width ="99" >< div  align ="center" >< strong > 金额 </ strong ></ div ></ td >
              
</ tr >
          
</ table >
              
< table  width ="100%"   border ="0"  cellspacing ="0"  cellpadding ="0" >
                
< tr >
                  
< td >< table  width ="724"  border ="1"  cellpadding ="0"  cellspacing ="1"  bordercolor ="#CCCCCC"  style ="border-collapse: collapse"  class ="doublecolortable"  id ="amount_price_total" >
                    
< tr >
                      
< td  width ="30"  height ="20" >< div  align ="center" > 1 </ div ></ td >
                      
< td  width ="187" >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td  width ="187" >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td  width ="97" >< div  align ="center" >
                          
< input  name ="amount12"  type ="text"  class ="input_2"  id ="amount12"  size ="10" >
                      
</ div ></ td >
                      
< td  width ="97" >< div  align ="center" >
                          
< input  name ="price12"  type ="text"  class ="input_2"  id ="price12"  size ="10" >
                      
</ div ></ td >
                      
< td  width ="99" >< div  align ="center" >
                          
< input  name ="total12"  type ="text"  class ="input_2"  id ="total12"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 2 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount22"  type ="text"  class ="input_2"  id ="amount22"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price22"  type ="text"  class ="input_2"  id ="price22"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total22"  type ="text"  class ="input_2"  id ="total22"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 3 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount32"  type ="text"  class ="input_2"  id ="amount32"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price32"  type ="text"  class ="input_2"  id ="price32"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total32"  type ="text"  class ="input_2"  id ="total32"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 4 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount42"  type ="text"  class ="input_2"  id ="amount42"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price42"  type ="text"  class ="input_2"  id ="price42"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total42"  type ="text"  class ="input_2"  id ="total42"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 5 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount52"  type ="text"  class ="input_2"  id ="amount52"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price52"  type ="text"  class ="input_2"  id ="price52"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total52"  type ="text"  class ="input_2"  id ="total52"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 6 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount62"  type ="text"  class ="input_2"  id ="amount62"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price62"  type ="text"  class ="input_2"  id ="price62"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total62"  type ="text"  class ="input_2"  id ="total62"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 7 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount72"  type ="text"  class ="input_2"  id ="amount72"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price72"  type ="text"  class ="input_2"  id ="price72"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total72"  type ="text"  class ="input_2"  id ="total72"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 8 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount82"  type ="text"  class ="input_2"  id ="amount82"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price82"  type ="text"  class ="input_2"  id ="price82"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total82"  type ="text"  class ="input_2"  id ="total82"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 9 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount92"  type ="text"  class ="input_2"  id ="amount92"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price92"  type ="text"  class ="input_2"  id ="price92"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total92"  type ="text"  class ="input_2"  id ="total92"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20" >< div  align ="center" > 10 </ div ></ td >
                      
< td >< input  name ="textfield33"  type ="text"  class ="input_1" ></ td >
                      
< td >< input  name ="textfield322"  type ="text"  class ="input_1" ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="amount102"  type ="text"  class ="input_2"  id ="amount102"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="price102"  type ="text"  class ="input_2"  id ="price102"  size ="10" >
                      
</ div ></ td >
                      
< td >< div  align ="center" >
                          
< input  name ="total102"  type ="text"  class ="input_2"  id ="total102"  size ="10" >
                      
</ div ></ td >
                    
</ tr >
                    
< tr >
                      
< td  height ="20"  colspan ="6" >< table  width ="100%"   border ="0"  cellspacing ="0"  cellpadding ="0" >
                        
< tr >
                          
< td > 合计人民币大写: < span  id ="tt" ></ span >   </ td >
                        
</ tr >
                      
</ table ></ td >
                      
</ tr >
                  
</ table ></ td >
                
</ tr >
              
</ table >
          
</ form ></ td >
        
</ tr >
      
</ table ></ td >
  
</ tr >
</ table >
</ body >
</ html >

转载于:https://www.cnblogs.com/CB/archive/2008/04/01/1133090.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值