数値を切り上げる
入力された数値を切り上げます。
切り上げにはceil()を使います。
[ 数値を切り上げる JavaScript ]
// 数値を切り上げる
function myCalc(form){
form.myResult3.value = Math.ceil(parseFloat(form.myData.value));
}
[ 数値を切り上げる XHTML ]
<?xml version="1.0" encoding="Shift_JIS"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja">
<head>
<title>タイトル</title>
<meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS" />
<meta name="description" content="サイト内容" />
<meta name="keywords" content="サイトキーワード" />
<meta name="author" content="css+xhtml+seo" />
<meta name="copyright" content="Copyright © css+xhtml+seo. All Rights Reserved." />
<link rel="index" href="./index.html" />
<link rel="next" href="next.html" />
<link rel="prev" href="prev.html" />
<link rev="made" href="mailto:●●●@●●●" title="send mail" />
<link rel="stylesheet" href="css/●●●.css" type="text/css" />
<script src="js/javascript.js" type="text/javascript"></script>
<meta http-equiv="content-script-type" content="" />
<meta http-equiv="content-style-type" content="text/javascript" />
</head>
<body>
<form name="form1">
<input type="text" name="myData" value="" /><br />
<input type="button" value="計算" onclick="myCalc(this.form)" /><br />
切り上げ<input type="text" name="myResult3" value="" /><br />
</form>
</body>
</html>

