array-numbers.html 765 B

12345678910111213141516171819202122232425262728293031323334353637
  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": "Numbers",
  17. "items": {
  18. "type": "number",
  19. "format": "number",
  20. "title": "Number"
  21. }
  22. };
  23. var editor = new JSONEditor(container, {
  24. schema: schema
  25. });
  26. document.querySelector('.get-value').addEventListener('click', function () {
  27. debug.value = JSON.stringify(editor.getValue());
  28. });
  29. </script>
  30. </body>
  31. </html>