<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>omtrek van een matras</title>
<script type="text/javascript" language="javascript">
<!-- hide from older browsers
function omtrek()
{
//get the values
var l = document.getElementById('lengte').value;
var b = document.getElementById('breedte').value;
var h = document.getElementById('hoogte').value;
var ppm = document.getElementById('ppm').value;
//get the numeric values
l = parseFloat(l);
b = parseFloat(b);
h = parseFloat(h);
ppm = parseFloat(ppm);
//check for numeric values
if (isNaN(l) || isNaN(b) || isNaN(h) || isNaN(ppm)) {
//display errormsg
document.getElementById('result').innerHTML = "Niet alle ingegeven waardes zijn numeriek!";
//back out
return;
}
//calculate
var omtrek = (l*b + b*h + l*h)/5000; //in m²
var prijs = ppm*omtrek;
//prijs afronden tot op de eurocent
prijs = Math.round(prijs*100)/100;
//display result
document.getElementById('result').innerHTML = "Omtrek van de matras = " + omtrek + "m²<br />Kostprijs van de stof voor die oppervlakte = <b>" + prijs + "</b> €";
}
//-->
</script>
</head>
<body>
<table cellspacing="3">
<tr>
<td>lengte:</td>
<td><input type="text" id="lengte" /></td>
</tr><tr>
<td>breedte:</td>
<td><input type="text" id="breedte" /></td>
</tr><tr>
<td>hoogte:</td>
<td><input type="text" id="hoogte" /></td>
</tr><tr>
<td>€/m²:</td>
<td><input type="text" id="ppm" /></td>
</tr>
</table>
<input type="button" value="bereken" onclick="omtrek();" />
<div id="result">Gelieve de correcte lengtes in te geven (in cm) en de prijs van je stof per m² (in €)</div>
</body>
</html>