I am working on a system that needs to represent an html form with typical elements like text field, select box, labels etc but it can only speak JSON or XML, not HTML.
I could always write my own JSON or XML converter and parser to represent the form in the required format but I would like to stick to certain standard, if it exists, for change management and extensibility. Also, the standard must have an existing Javascript parser.
I was looking at XUL but it doesn't seem to have form tags and looks like a DSL suitable only for Mozilla based applications. Also I was unable to find a Javascript parser for the same.
I believe this should be a fairly common problem that somebody has solved but I'm unable to find it. Any pointers would be much appreciated.
The elements used in an HTML form are check box, input box, radio buttons, submit buttons etc. Using these elements the information of an user is submitted on a web server. The form tag is used to create an HTML form.
Form tags are still necessary if you want to be able to submit the form without AJAX (which may be useful in the early stages of development).
An HTML form is a section of a document containing normal content, markup, special elements called controls (checkboxes, radio buttons, menus, etc.), and labels on those controls.
The standard representation for HTML forms is... HTML forms.
As far as I know, no-one’s invented an alternative way to represent them because, well, why would you? They’re declarative already.
Thankfully, given that HTML can be written as XML (we call that XHTML), XHTML forms already satisfy your XML requirement.
As far as parsing them in JavaScript goes, it depends what you mean by parsing. John Resig is working on a full HTML parser in JavaScript, but if you’re just looking to read/write values via the DOM, you can do that in JavaScript.
The spec for HTML forms is here:
The spec for how to write HTML as XML is the XHTML 1.0 spec:
If you’d rather use HTML5 forms, which adds some new form fields (see http://diveintohtml5.ep.io/forms.html), the relevant specs are:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With