Paste: aa

Author: ee
Mode: html
Date: Wed, 28 Mar 2012 15:59:28
Plain Text |
<!DOCTYPE html>
<html>
		<head>
				<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
				<title></title>
				<script type="text/javascript">
						function change(obj){
								var i = 0;
								var unit = 0;
								var currencyValue = [100,50,20,10,5,1,0.25,0.10,0.05,0.01];
								var userInput = obj.parentNode.userInput.value;
								userInput = parseFloat(userInput);
								for(i;i<=9;i++){
										if(userInput >= currencyValue[i]){
												unit = Math.floor(userInput/currencyValue[i]);
												userInput = userInput - (unit * currencyValue[i]);
										} else {
												unit = 0;
										}
										document.getElementById(i).innerHTML = unit;
								}
								return false;
						}
				</script>
		</head>
		<body>
				<form>
						<input type="text" name="userInput" value="" />
						<input onclick="return change(this)" type="submit" value="enviar" />
				</form>
				<table>
						<tr>
								<td id="0"></td>
								<td id="1"></td>
								<td id="2"></td>
								<td id="3"></td>
								<td id="4"></td>
								<td id="5"></td>
								<td id="6"></td>
								<td id="7"></td>
								<td id="8"></td>
								<td id="9"></td>
						</tr>
				</table>
		</body>
</html>

New Annotation

Summary:
Author:
Mode:
Body: