Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>vezba2</title>
  6. <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
  7. </head>
  8. <body>
  9. <form>
  10. <label>Number of elements</label><input id="number" type="text" value=""><br><br>
  11. <label>Type</label>
  12. <select id="type">
  13. <option value="CheckBox">CheckBox</option>
  14. <option value="Radio">Radio</option>
  15. </select>
  16. </form><br><br>
  17. <button id="kopce" onclick="myFunction()">hghghg</button>
  18. <div id="result"></div>
  19. </body>
  20. <script>
  21. function myFunction() {
  22. console.log("HA");
  23. var n = document.getElementById("number").value;
  24. parseInt(n);
  25. for (var i = 0; i < n; i++) {
  26. var radioBtn = document.createElement('input');
  27. radioBtn.setAttribute('type', 'radio');
  28. document.getElementById("result").appendChild(radioBtn);
  29.  
  30. }
  31. }
  32. /* $(document).ready(function () {
  33. console.log("OK");
  34.  
  35.  
  36. $("#kopce").click(function () {
  37. var n = document.getElementById("number").value;
  38. parseInt(n);
  39. for (i = 0; i < n; i++) {
  40. var radioBtn = $('<input type="radio" name="rbtnCount" value="i"/>');
  41. radioBtn.appendTo('#result');
  42. }
  43.  
  44. });
  45. });*/
  46. </script>
  47. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement