Last active
October 4, 2015 14:28
-
-
Save ryuichimatsumoto-single/2653164 to your computer and use it in GitHub Desktop.
Calculate Gasoline costs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<style type="text/css"> | |
body | |
{ | |
width:260px; | |
color:#ffffff; | |
} | |
body | |
{ | |
background-color: #000000; | |
border: 2px solid #ffffff; | |
-moz-border-radius: 23px; | |
-webkit-border-radius: 23px; | |
border-radius: 23px; | |
/*IE 7 AND 8 DO NOT SUPPORT BORDER RADIUS*/ | |
} | |
div#wrap | |
{ | |
padding-left:12px; | |
} | |
input, select | |
{ | |
width: 75px; | |
} | |
input.deside_button | |
{ | |
width:200px; | |
} | |
textarea | |
{ | |
width: 300px; | |
height: 7em; | |
} | |
input, select, textarea | |
{ | |
background-color: #000000; | |
color:#ffffff; | |
} | |
option | |
{ | |
background-color: #000000; | |
color:#ffffff; | |
} | |
</style> | |
<script language="Javascript"> | |
//costs(money) = running distance(km) ÷ running distance per little gasoline(km/l ) * costs of gasoline per little(money/l) | |
/* | |
*Outputgasoline:Calclating Gasoline ver 1.2 | |
*result is writtened. | |
*@var distance:distance you'll run(km) | |
*@var little: running distance per little gasoline (km/l) | |
*@var little:(money/ℓ) | |
*/ | |
function Outputgasoline(distance,little,gasoline) | |
{ | |
var result = document.getElementById("result"); | |
result.innerHTML = Math.round(parseInt(distance) * parseInt(gasoline) / parseInt(little)); | |
return false; | |
} | |
</script> | |
<body> | |
<form name="form"> | |
<div id="wrap"> | |
<table border="0"> | |
<tr> | |
<td>走行距離(km):</td> | |
<td><input type="number" name="content"></td> | |
</tr> | |
<tr> | |
<td>燃費(km/ℓ):</td> | |
<td><input type="number" name="content"></td> | |
</tr> | |
<tr> | |
<td>ガソリン代(円/ℓ):</td> | |
<td><input type="number" name="content"></td> | |
</tr> | |
<!-- | |
<tr> | |
<td>ガソリン代(円/ℓ):</td> | |
<td><input type="number" name="content"></td> | |
</tr> | |
--> | |
</table> | |
<!-- | |
<input type="button" onclick="alert(CalcGasoline(document.form.content[0].value,document.form.content[1].value,document.form.content[2].value))"> | |
--> | |
<input type="button" class="deside_button" value="計算" onclick="Outputgasoline(document.form.content[0].value,document.form.content[1].value,document.form.content[2].value)"> | |
</form> | |
<!--outputs of total gasoline cost after released button--> | |
<p>トータルコスト:<span id="result"></span>円</p> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment