Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

public_html/exercises/

Projekt/
cm.html
formPostTest/
index.html
javascript.html
ovning0.html
ovning01.html
ovning02.html
ovning03.html
ovning04.html
ovning06.html
ovning07.html
ovning08.html
ovning09.css
ovning09ap.html
ovning09app.html
ovning09ba.html
ovning10.html
ovningjs02.html
piano.html
quizeovning.php
spel.html
test.html

cm.html

38 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .cm {
            background-color: #000000;
            height: 1cm;
            width: 1cm;
        }
    </style>
</head>
<body>
    <label for="length">längd</label>
    <input type="number" id="length" value="0">
    <button id="b" type="button">Set</button>
    <div id="ruler"></div>
    <script>
        const ruler = document.getElementById("ruler")
        const lengthInput = document.getElementById("length")
        const button = document.getElementById("b")

        button.addEventListener("click", function() {
            let length = lengthInput.value
            console.log(length)
            let i = 0
            ruler.innerHTML = ""
            while (i < length) {
                ruler.innerHTML += "<div class='cm'></div> "
                i = i + 1
            }
        })
        
    </script>
</body>
</html>