Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>vezba2</title>
- <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
- </head>
- <body>
- <form>
- <label>Number of elements</label><input id="number" type="text" value=""><br><br>
- <label>Type</label>
- <select id="type">
- <option value="CheckBox">CheckBox</option>
- <option value="Radio">Radio</option>
- </select>
- </form><br><br>
- <button id="kopce" onclick="myFunction()">hghghg</button>
- <div id="result"></div>
- </body>
- <script>
- function myFunction() {
- console.log("HA");
- var n = document.getElementById("number").value;
- parseInt(n);
- for (var i = 0; i < n; i++) {
- var radioBtn = document.createElement('input');
- radioBtn.setAttribute('type', 'radio');
- document.getElementById("result").appendChild(radioBtn);
- }
- }
- /* $(document).ready(function () {
- console.log("OK");
- $("#kopce").click(function () {
- var n = document.getElementById("number").value;
- parseInt(n);
- for (i = 0; i < n; i++) {
- var radioBtn = $('<input type="radio" name="rbtnCount" value="i"/>');
- radioBtn.appendTo('#result');
- }
- });
- });*/
- </script>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement