I have a web app that has a big and complex form (fields, checks, etc).
I hade using standard OS form controls because they have visual (styling) limits.
I have been basically creating spans with IDs and attaching class or custom data attributes. I later need to send this to a PHP script for insertion into a database. This has worked well in the past, but I’m having to do a lot of manual processing of fields, which I don’t think is efficient… Is there a better way?
I currently do,
IF ($('#foo').hasClass('on')){bar=1}
…
Then I manually compose a POST string via
foo=bar&bla=blabla ...
Then lots more on the PHP side to create an insert SQL statement.
Seems like its inefficient if you have dozens of fields… But I hate standard FORM elements…
Any suggestions? …. Loops? Arrays?
You could use jQuery’s serialize() method:
jsFiddle example