Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <!-- This was one of my first javascript projects :) -->
- <head>
- <meta charset="UTF-8">
- <title>Char Randomizer 1.2</title>
- </head>
- <body>
- <b>Enter some text:</b>
- <br><br>
- <section>
- <form>
- <textarea rows="10" cols="30" id="textInput" >Welcome to the Randomizer 1.2!</textarea><br>
- <input type="button" onclick="randomizeChars()" value="Randomiue!">
- </form>
- </section>
- <section>
- <br>
- <h3>Result:</h3>
- <textarea type="text" id="textOutput" readonly rows="10" cols="30"></textarea>
- </section>
- <script>
- function randomizeChars() {
- var originalText = document.getElementById("textInput").value;
- var neuerText = "";
- for (i = 0; i < originalText.length; i++) {
- if(Math.round(Math.random()) == 0) {
- if(originalText.charAt(i) == "!") { //Ausrufezeichen durch 1 ersetzten
- neuerText += "1";
- } else {
- neuerText += originalText.charAt(i).toUpperCase();
- }
- } else {
- neuerText += originalText.charAt(i).toLowerCase();
- }
- }
- document.getElementById("textOutput").innerHTML = neuerText;
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment