Advertisement
RandomGuy32

Bananenpudding

Feb 4th, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <html>
  2. <head>
  3. <title>
  4.     Test: Teilbarkeit
  5. </title>
  6. <meta name="author" content="Eiffel Buff" />
  7. <!-- Script -->
  8. <script type="text/javascript">
  9.     function fTeilbar() {
  10.         // Reinziehen der beiden Eingaben
  11.         var intInput1 = parseInt(document.getElementById("txtInput1").value);
  12.         var intInput2 = parseInt(document.getElementById("txtInput2").value);
  13.         // Programm...-kern? Nennt man das so?
  14.         if (intInput2 == 0) {
  15.             // Spezialmeldung weil wegen Division durch 0
  16.             window.alert("Hey! Durch 0 wird nicht dividiert!");
  17.             }
  18.         else if (intInput1 % intInput2 == 0) {
  19.             // Wenn teilbar (also Rest 0)
  20.             window.alert("Hurra! " + intInput1 + " ist restlos durch " + intInput2 + " teilbar.");
  21.             }
  22.         else {
  23.             // Wenn nicht teilbar (also Rest nicht 0)
  24.             window.alert("Schade. " + intInput1 + " kann man nicht ohne Rest durch " + intInput2 + " teilen.");
  25.             }
  26.         }
  27. </script>
  28. <!-- Stylesheet -->
  29. <style type="text/css">
  30.     hr {
  31.         margin-top: 10px;
  32.         margin-bottom: 10px;
  33.         width: 143px;
  34.         height: 2px;
  35.         text-align: left;
  36.         margin-left: 0px;
  37.         }
  38. </style>
  39. </head>
  40. <body>
  41. <h1>
  42.     Teilbarkeit zweier Zahlen
  43. </h1>
  44. <p>
  45.     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.
  46. </p>
  47. <input id="txtInput1" type="text" value="Erste Zahl" />
  48. <hr />
  49. <input id="txtInput2" type="text" value="Zweite Zahl" />
  50. <br />
  51. <br />
  52. <br />
  53. <input id="btnStart" type="button" value="Los!" onClick="fTeilbar()" />
  54. <!-- NoScript -->
  55. <noscript>
  56.     Ey, machst du JavaScript an oder was!?
  57. </noscript>
  58. </body>
  59. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement