array-ratings.html 851 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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": "Rating",
  19. "type": "integer",
  20. "format": "rating",
  21. "maximum": "5",
  22. "exclusiveMaximum": false
  23. }
  24. };
  25. var editor = new JSONEditor(container, {
  26. schema: schema,
  27. startval: [1,2,3,4,5]
  28. });
  29. document.querySelector('.get-value').addEventListener('click', function () {
  30. debug.value = JSON.stringify(editor.getValue());
  31. });
  32. </script>
  33. </body>
  34. </html>