zoukankan
html css js c++ java
表单自动计算问题
销售开单
单据编号:
客户名称:
收款方式:
请选择收款方式
仓库:
请选择仓库
备注:
序号
货品编码
货品名称
数量
单价
金额
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"
>
<
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"
>
<
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
>
<
select
name
="select2"
class
="S_input"
>
<
option
selected
>
请选择收款方式
</
option
>
</
select
></
td
>
<
td
><
div
align
="right"
>
仓库:
</
div
></
td
>
<
td
>
<
select
name
="select"
class
="S_input"
>
<
option
selected
>
请选择仓库
</
option
>
</
select
></
td
>
</
tr
>
<
tr
>
<
td
><
div
align
="right"
>
备注:
</
div
></
td
>
<
td
colspan
="3"
>
<
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
>
查看全文
相关阅读:
Python之sys & os
1161
1142
P1599 货币
P1547逆转,然后再见
P1629八
P1753HackSon的趣味题
Problem 2233 ~APTX4869
1269
1091. Tmutarakan Exams
原文地址:https://www.cnblogs.com/CB/p/1133090.html
最新文章
梦断代码阅读笔记02
YJC tricks time HDU 5276
Prime Path POJ 3126
Ugly Numbers POJ 1338
Silver Cow Party poj 3268
无向图求桥 UVA 796
无向图求割点 UVA 315
连通图 hdu 1269
js小例子(标签页)
JS日期函数
热门文章
JS小函数
jquery(ajax)与js(ajax)的比较
解决js(ajax)提交后端的“ _xsrf' argument missing from POST” 的错误
js与jquery异同
运用datalist标签实现用户的搜索列表
解决js小数求和出现多位小数问题
Python多线程/单线程
Python 异常处理
Python之 加密模块
Python之操作Excel
Copyright © 2011-2022 走看看