3

I built a script (classic asp) that generates simple forms from DB tables. I give it a table name, and it generates an HTML page with a form in it. for each field in the table, it generates an input box in the form.

It will be very easy for me to also create a javascript object in each page that will describe each form input (values expected, optional or not, default value etc...)

My question is is there a jquery plugin (or something similar) that knows how to take data like that, and replace each input with something more suited.

Thanks, Ami

Ami Malimovka
  • 437
  • 7
  • 22
  • What does "more suited" mean? Why not just create plain form elements and use something like jquery validator plugin? – lucuma Jun 12 '12 at 14:51
  • I suspect you'll need to do this yourself, since it will be difficult to completely define this form outside of HTML. Cool idea though, and it should be fairly simple to do. – Brad Jun 12 '12 at 14:51
  • @lucuma: He means change the input boxes to checkboxes, radio/selects, etc. – Madara's Ghost Jun 12 '12 at 15:01
  • In order to answer this question the OP would need to post code. Building a form isn't terribly difficult. Doing validations and everything else might add some complexity. – lucuma Jun 12 '12 at 15:03

1 Answers1

0

I don't know of any of such plugin, what you could (and should) do, is look at the Data Types from the database, if the field is an INT (SHORTINT, BIGINT), use <input type=number>, if it's a BOOL, use <input type=checkbox>, if it's an ENUM, use <input type=radio>, etc.

This should be done at server side, not client side. Don't rely on JavaScript for critical usability features.

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
  • well... this was a very specific situation. Finally I wrote my own solution, I marked each form input with a specific class name, and added (when necessary) data-*** attributes. After that I used jquery to render the inputs (sometimes slightly modifying them, and sometimes completely replacing them ). The reason I didn't do this server side was that those pages were created once, as part of a prototyping process, and afterwards were altered (by several programmers). the rendering of the form inputs was expected to change (and did) and will probably change again in the future. – Ami Malimovka Jul 08 '12 at 12:56