对位拆分数字金额

效果图:
亿
12 4567 8985
亿
8 9465 4633
代码: <!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>拆分金额</title>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script>
$(function(){
initPage();
});
function initPage() {
var issueList = ["issueFen", "issueJiao", "dian", "issueYuan", "issueShi", "issueBai",
"issueQian", "issueWan", "issueShiW", "issueBaiW", "issueQianW", "issueYi"];
var availableList = ["availableFen", "availableJiao", "dian",
"availableYuan", "availableShi","availableBai", "availableQian",
"availableWan", "availableShiW", "availableBaiW", "availableQianW", "availableYi"];
var str1 = "12456789.85";
var str2 = "8946546.33";
readAmount(str1, issueList);
readAmount(str2, availableList);
}
function readAmount(str, list) {
var size = str.length;
for (var i=0; i<size; i++) {
$("#"+ list[i]).html(str.substring(str.length-1));
str = str.substring(0, str.length-1);
}
}
</script>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="5">
<tr><td>亿</td><td>仟</td><td>佰</td><td>拾</td><td>万</td><td>仟</td><td>佰</td><td>拾</td><td>元</td><td>角</td><td>分</td></tr>
<tr><td id="issueYi"></td><td id="issueQianW"></td><td id="issueBaiW"></td>
<td id="issueShiW"></td><td id="issueWan"></td><td id="issueQian"></td><td id="issueBai"></td>
<td id="issueShi"></td><td id="issueYuan"></td><td id="issueJiao"></td><td id="issueFen"></td>
</tr>
<tr><td>亿</td><td>仟</td><td>佰</td><td>拾</td><td>万</td><td>仟</td><td>佰</td><td>拾</td><td>元</td><td>角</td><td>分</td></tr>
<tr><td id="availableYi"></td><td id="availableQianW"></td><td id="availableBaiW"></td>
<td id="availableShiW"></td><td id="availableWan"></td><td id="availableQian"></td><td id="availableBai"></td>
<td id="availableShi"></td><td id="availableYuan"></td><td id="availableJiao"></td><td id="availableFen"></td>
</tr>
</table>
</html>
posted @ 2019-04-26 17:35  云飞扬-88  阅读(188)  评论(0编辑  收藏  举报