首页 > 代码库 > js实现小写转大写,js实现数字转人民币
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 = http://www.mamicode.com/china;
}
function clearnumber() {
document.getElementById("number").value = http://www.mamicode.com/"";
document.getElementById("newnumber").value = http://www.mamicode.com/"";
}
function promptMessage() {
document.getElementById("number").value = http://www.mamicode.com/"小数点后保留两位小数";
}
function clearMessage() {
document.getElementById("number").value = http://www.mamicode.com/"";
}
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=http://www.mamicode.com/"转换" onclick="transformNumber();" />
<input type="button" id="clear" value=http://www.mamicode.com/"清零" onclick="clearnumber();">
</div>
</body>
</html>
<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 = http://www.mamicode.com/china;
}
function clearnumber() {
document.getElementById("number").value = http://www.mamicode.com/"";
document.getElementById("newnumber").value = http://www.mamicode.com/"";
}
function promptMessage() {
document.getElementById("number").value = http://www.mamicode.com/"小数点后保留两位小数";
}
function clearMessage() {
document.getElementById("number").value = http://www.mamicode.com/"";
}
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=http://www.mamicode.com/"转换" onclick="transformNumber();" />
<input type="button" id="clear" value=http://www.mamicode.com/"清零" onclick="clearnumber();">
</div>
</body>
</html>
js实现小写转大写,js实现数字转人民币
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。