title: ColdFusion Insert multiple form fields with one submit
body: <p><strong>Summary:</strong></p>
  
  <p>I have a CFC that successfully inserts a single set of form fields into a database table. Now I want to modify it to insert multiple records, but am getting an error when I try to process the dynamic form field names.</p>
  
  <p><strong>Detail:</strong></p>
  
  <p>I have (5) form fields that need to be inserted in to the db at the same time, as different rows. So I looped and incremented the field number. I created 5 static rows for it to be simple.</p>
  
  <pre><code>&lt;cfloop index="x" from="1" to="5"&gt; 
   &lt;cfoutput&gt;
      &lt;input name="ITIProgramName#x#" type="text" ..&gt;
      &lt;input name="ITIProgVer#x#" type="text" ..&gt;
    &lt;/tr&gt;
   &lt;/cfoutput&gt;
   &lt;/cfloop&gt;
  </code></pre>
  
  <p>So the result is: </p>
  
  <ul>
  <li>ITIPROGRAMNAME1, ITIProgVer1</li>
  <li>ITIPROGRAMNAME2, ITIProgVer2</li>
  <li>ITIPROGRAMNAME3, ITIProgVer3</li>
  <li>... </li>
  </ul>
  
  <p>I tried to insert the fields into the database by looping like so:</p>
  
  <pre><code>&lt;cfloop from="1" to="5" index="x" &gt;
  
      &lt;cfquery datasource="ITSReporting" name="InsertQuery"&gt;
      INSERT INTO ITIPRO
          (   ServerID,
              ServerName,
              ProgramName,
              CurrentProgVer,
              LastUser,
              UpDone  )
      VALUES
          (   '#Form.ServerID#',
              '#Form.ServerName#',
              '#Form[ITIProgramName#x#]#',
              '#Form[ITIProgVer#x#]#',
              '#CGI.Auth_User#',
              #CreateODBCDateTime(Now())#
              )
  &lt;/cfquery&gt;
  &lt;/cfloop&gt;
  </code></pre>
  
  <p>But it produces the Error</p>
  
  <blockquote>
    <p>Invalid CFML construct</p>
  </blockquote>
  
  <p>I've tried all sorts of things, but cannot find the right syntax. Any suggestions would be much appreciated. </p>