title: Add dynamic form fields to database
body: <p>I have some ideas how to tackle this, but it must be a relatively common thing to do and I wondered if there is a 'standard' way to tackle it.</p>
  
  <p>Basically I have a form on an HTML page which uses jQuery AJAX to post to an ASP.NET page, which then takes the form fields and puts them into a database.</p>
  
  <p>The form itself contains some standard fields, such as article title, article content and date.  However, the form also allows for numerous author details to be added, comprising author name, author email address, author age.  So on the form, the user fills in the form title and content fields and can add one or more authors, the fields for which are built dynamically using jQuery.clone().</p>
  
  <p>So there is an unknown number of authors, and as a result the .NET control which accepts the form post doesn't know what fields it is due to receive.</p>
  
  <p>The standard form details are added to one table, called 'Article'.  The authors are each individually added to a different table, called 'Author'.</p>
  
  <p>So the question is, what is the best way to handle this type of thing?</p>
  
  <p>Thanks for any advice here.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>To add my initial ideas to this...  Firstly, I could name each of the author form fields with an incremental number, like this:</p>
  
  <pre><code>&lt;fieldset&gt;
    Author 1 name: &lt;input name="name-1" /&gt;&lt;br /&gt;
    Author 1 email: &lt;input name="email-1" /&gt;&lt;br /&gt;
    Author 1 age: &lt;input name="age-1" /&gt;
  &lt;/fieldset&gt;
  &lt;fieldset&gt;
    Author 2 name: &lt;input name="name-2" /&gt;&lt;br /&gt;
    Author 2 email: &lt;input name="email-2" /&gt;&lt;br /&gt;
    Author 2 age: &lt;input name="age-2" /&gt;
  &lt;/fieldset&gt;
  </code></pre>
  
  <p>And also have a hidden field called 'number-of-authors' which is incremented/decremented when new author fieldsets are added/removed by the jQuery script.  Then in the .NET code which receives the form post, I could loop through each form field from 0 to x (where x is the value of 'number-of-authors'.  The difficulty here is I'd have to re-index each of the form fields when a fieldset is removed, in case the user deletes the first set, for example.</p>
  
  <p>My second thought is that I could use jQuery serialisation to serialise the form field values into a single string, then process that string back into an object in the .NET code.  Although I don't really know how to do this, I'm sure it would be possible.</p>
  
  <p>What would people's advice be in this situation?</p>