Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>
- Test: Teilbarkeit
- </title>
- <meta name="author" content="Eiffel Buff" />
- <!-- Script -->
- <script type="text/javascript">
- function fTeilbar() {
- // Reinziehen der beiden Eingaben
- var intInput1 = parseInt(document.getElementById("txtInput1").value);
- var intInput2 = parseInt(document.getElementById("txtInput2").value);
- // Programm...-kern? Nennt man das so?
- if (intInput2 == 0) {
- // Spezialmeldung weil wegen Division durch 0
- window.alert("Hey! Durch 0 wird nicht dividiert!");
- }
- else if (intInput1 % intInput2 == 0) {
- // Wenn teilbar (also Rest 0)
- window.alert("Hurra! " + intInput1 + " ist restlos durch " + intInput2 + " teilbar.");
- }
- else {
- // Wenn nicht teilbar (also Rest nicht 0)
- window.alert("Schade. " + intInput1 + " kann man nicht ohne Rest durch " + intInput2 + " teilen.");
- }
- }
- </script>
- <!-- Stylesheet -->
- <style type="text/css">
- hr {
- margin-top: 10px;
- margin-bottom: 10px;
- width: 143px;
- height: 2px;
- text-align: left;
- margin-left: 0px;
- }
- </style>
- </head>
- <body>
- <h1>
- Teilbarkeit zweier Zahlen
- </h1>
- <p>
- Geben Sie zwei ganze Zahlen ein und drücken Sie dann das Knöpfchen, um zu prüfen, ob die erste Zahl durch die zweite teilbar ist.
- </p>
- <input id="txtInput1" type="text" value="Erste Zahl" />
- <hr />
- <input id="txtInput2" type="text" value="Zweite Zahl" />
- <br />
- <br />
- <br />
- <input id="btnStart" type="button" value="Los!" onClick="fTeilbar()" />
- <!-- NoScript -->
- <noscript>
- Ey, machst du JavaScript an oder was!?
- </noscript>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement