Lorem Text Generator tool code

 

<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Lorem Text Generator</title>

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css">

    <style>

        body {

            background: linear-gradient(to right, #ff7e5f, #feb47b);

            font-family: Arial, sans-serif;

            color: #fff;

        }

        .container {

            margin-top: 50px;

            padding: 20px;

            background-color: rgba(0, 0, 0, 0.8);

            border-radius: 10px;

            box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);

        }

        h1 {

            text-align: center;

            margin-bottom: 30px;

            font-size: 2.5rem;

        }

        label {

            font-size: 1.2rem;

        }

        .btn {

            background-color: #ff5722;

            border: none;

        }

        .btn:hover {

            background-color: #e64a19;

        }

        textarea {

            background-color: #2e2e2e;

            color: #fff;

            border: 1px solid #444;

            resize: none;

        }

    </style>

</head>

<body>

    <div class="container">

        <h1>Lorem Text Generator</h1>

        <form id="loremForm">

            <div class="mb-3">

                <label for="paragraphCount" class="form-label">Number of Paragraphs:</label>

                <input type="number" id="paragraphCount" class="form-control" min="1" max="20" value="1" required>

            </div>

            <div class="mb-3">

                <label for="wordCount" class="form-label">Words per Paragraph:</label>

                <input type="number" id="wordCount" class="form-control" min="10" max="200" value="50" required>

            </div>

            <div class="d-grid gap-2">

                <button type="submit" class="btn btn-primary btn-lg">Generate</button>

            </div>

        </form>

        <div class="mt-4">

            <label for="output" class="form-label">Generated Lorem Text:</label>

            <textarea id="output" class="form-control" rows="10" readonly></textarea>

        </div>

    </div>


    <script>

        const loremWords = [

            "lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "sed", "do",

            "eiusmod", "tempor", "incididunt", "ut", "labore", "et", "dolore", "magna", "aliqua", "ut",

            "enim", "ad", "minim", "veniam", "quis", "nostrud", "exercitation", "ullamco", "laboris", "nisi",

            "ut", "aliquip", "ex", "ea", "commodo", "consequat", "duis", "aute", "irure", "dolor", "in",

            "reprehenderit", "in", "voluptate", "velit", "esse", "cillum", "dolore", "eu", "fugiat", "nulla",

            "pariatur"

        ];


        const loremForm = document.getElementById("loremForm");

        const paragraphCountInput = document.getElementById("paragraphCount");

        const wordCountInput = document.getElementById("wordCount");

        const output = document.getElementById("output");


        loremForm.addEventListener("submit", function(event) {

            event.preventDefault();


            const paragraphCount = parseInt(paragraphCountInput.value);

            const wordCount = parseInt(wordCountInput.value);


            let loremText = "";


            for (let i = 0; i < paragraphCount; i++) {

                let paragraph = [];

                for (let j = 0; j < wordCount; j++) {

                    const randomIndex = Math.floor(Math.random() * loremWords.length);

                    paragraph.push(loremWords[randomIndex]);

                }

                loremText += paragraph.join(" ") + "\n\n";

            }


            output.value = loremText.trim();

        });

    </script>

</body>

</html>


Admin

A Software Engineer, Social Media Marketing Expert, writer,

Post a Comment

Previous Post Next Post