首页 > 代码库 > javascript 小例子(待补充)

javascript 小例子(待补充)

<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script>
		function figure1(){
			var figure = money.value;
			var wushi = Math.floor(figure/50);
			var ershi = Math.floor(figure%50/20);
			var shiyuan = Math.floor(figure%50%20/10);
			var wuyuan = Math.floor(figure%50%20%10/5);
			var yiyuan = Math.floor(figure - wushi*50 - ershi*20 - shiyuan*10 - wuyuan*5); 
			//alert(figure);
			show.innerHTML = figure+"="+"50:"+wushi+"  20:"+ershi+"  10:"+shiyuan+"  5:"+wuyuan+"  1:"+yiyuan;
		}
	</script>
</head>
<body>
	<form action="">
		找零金额:<input type="text" name="money" id="money"><br>  
		<input type="button" value=http://www.mamicode.com/"计算金额" onclick="figure1()">  >