使用JQuery从JSON或XML提要生成HTML表单
我想使用Jquery创建基于XML或JSON数据的HTML表单,我还计划validation任何可能为空或不正确的表单字段。
我想知道是否有任何其他程序/函数动态生成这样的表单,并且是实现此目的的最佳方式。 任何jquery小部件或库最适合工作示例将非常感激
以及在这种情况下最佳使用XML或JSON的原因并解释原因?
谢谢
我发现其中一些可能会对你有所帮助:
从JSON模式生成表单:
- 如何使用JSON定义创建html表单?
- http://neyric.github.com/inputex/examples/json-schema.html
- 用于从JSON或类似数据生成/呈现动态HTML表单的JavaScript?
- 任何生成html表单的工具
从XML模式生成表单:
- http://www.totallysmartit.com/examples/xml/questionnaire/
- 从XML创建HTML表单
- http://www.datamech.com/XMLForm/
来自不同库的样本生成表单:
只是给你另一个选择,我创建了一个库:
https://github.com/brutusin/json-forms
JSON Schema到HTML表单生成器,支持动态子表单(即时解析)。 具有零依赖性的可扩展和可自定义的库。 提供了Bootstrap附加组件
var bf = brutusin["json-forms"].create({ "$schema": "http://json-schema.org/draft-03/schema#", "type": "object", "properties": { "s1": { "type": "string", "title": "A string", "description": "A string input" }, "num1": { "type": "integer", "title": "A number", "minimum": 1, "maximum": 10, "multipleOf": 3, "description": "An integer multiple of `3`, between `1` and `10` (inclusive)" }, "array1": { "type": "array", "title": "An array values", "items": { "type": "object", "properties": { "value": { "type": "string", "title": "Value" } } } } } }); var container = document.getElementById('container'); bf.render(container);