array-checkboxes.html 864 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8"/>
  5. <script src="../../dist/jsoneditor.js"></script>
  6. </head>
  7. <body>
  8. <textarea class="debug" cols="30" rows="10"></textarea>
  9. <button class='get-value'>Get Value</button>
  10. <div class='container'></div>
  11. <script>
  12. var container = document.querySelector('.container');
  13. var debug = document.querySelector('.debug');
  14. var schema = {
  15. "type": "array",
  16. "title": "Checkboxes",
  17. "items": {
  18. "title": "Checkbox",
  19. "type": "array",
  20. "uniqueItems": true,
  21. "items": {
  22. "type": "string",
  23. "enum": ["1", "2", "3", "4", "5"]
  24. }
  25. }
  26. };
  27. var editor = new JSONEditor(container, {
  28. schema: schema
  29. });
  30. document.querySelector('.get-value').addEventListener('click', function () {
  31. debug.value = JSON.stringify(editor.getValue());
  32. });
  33. </script>
  34. </body>
  35. </html>