File size: 2,511 Bytes
a75f50b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>

<head>
    <style>
        body {
            font-family: Arial, sans-serif;
        }

        .container {
            max-width: 600px;
            margin: 20px auto;
            padding: 20px;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        input[type="text"] {
            width: 100%;
            padding: 10px;
            margin: 10px 0;
        }

        input[type="checkbox"] {
            margin-right: 10px;
        }

        .result {
            margin-top: 20px;
        }

        button {
            padding: 10px 20px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        button:hover {
            background-color: #45a049;
        }
    </style>
</head>

<body>
    <div class="container">
        <input type="text" id="textInput" placeholder="Enter text with ❒ separated words">
        <button onclick="createCheckboxes()">Create Checkboxes</button>

        <div id="checkboxContainer"></div>

        <button onclick="showResult()">Result</button>
        <input type="text" id="resultInput">

    </div>

    <script>
        function createCheckboxes() {
            var text = document.getElementById("textInput").value;
            var words = text.split("❒");

            var checkboxContainer = document.getElementById("checkboxContainer");
            checkboxContainer.innerHTML = "";

            words.forEach(function(word) {
                if (word.trim() !== "") {
                    var label = document.createElement("label");
                    var checkbox = document.createElement("input");
                    checkbox.type = "checkbox";
                    checkbox.value = word.trim();
                    label.appendChild(checkbox);
                    label.appendChild(document.createTextNode(word.trim()));
                    checkboxContainer.appendChild(label);
                }
            });
        }

        function showResult() {
            var checkboxes = document.querySelectorAll("#checkboxContainer input[type='checkbox']");
            var result = [];
            checkboxes.forEach(function(checkbox) {
                if (checkbox.checked) {
                    result.push(checkbox.value);
                }
            });
            document.getElementById("resultInput").value = result.join(", ");
        }
    </script>
</body>

</html>