Beispiel:JS-math.floor.html
Aus SELFHTML-Wiki
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" media="screen" href="./Beispiel:SELFHTML-Beispiel-Grundlayout.css" />
<style>
form {
width: 12em;
}
input {
margin: 0 0 1em 1em;
}
label {
float: left;
text-align: right;
width: 10em;
}
.button {
margin-left: 11em;
}
</style>
<title>Beispiel: math.floor</title>
</head>
<body>
<h1>Beispiel: math.floor </h1>
<main>
<p>Bitte geben Sie eine Zahl ein und drücken Sie auf den Button.</p>
<form name="Test" action="">
<input type="text" name="Eingabe" >
<input type="button" value="=" onclick="Berechnen(Eingabe)">
</form>
<p id="Ausgabe"></p>
</main>
<script>
function Berechnen (zahl) {
zahl = Math.floor(zahl.value);
var elem = document.getElementById('Ausgabe');
elem.innerHTML = 'Die nächstniedrigere Ganzzahl ist: '+ zahl;
}
</script>
</body>
</html>