0 Replies Latest reply on Apr 22, 2014 9:22 AM by jlig

    Single CF Form to Add "x" Number of Voice & Data (Related) Records

    jlig Level 1

      I have an older functioning form that creates a new "Order" record in my "tblCOM" table

      Add_x_number_of_records.PNG

       

      I added two new text type fields called: "HowManyData" & "HowManyVoice" (see image above) and a new field called "pvType"

       

      Question: How can I adapt my page to handle the following scenario:

      ------------------------------------------------------------------------------------------ -

      - the user types in a qty of "4" for field "HowManyData"

      - the user types in a qty of "2" for field "HowManyVoice"

       

      When the Submit button is pressed:

      -----------------------------------------------

      - the main record is added to "tblCOM" (this is already working fine)

      - four (4) related  "Data" records are added to the "tblProvisioning" table (and pvType is saved w/value of "Data")

      - four (2) related "Voice" records are added to the "tblProvisioning" table (and pvType is saved w/value of "Voice")

       

       

      I know this requires something similar to the following:

      -----------------------------------------------------------------------

      <cfquery name="simpleInsert" datasource="mydatasource">
      INSERT INTO tblProvisioning (col1,col2,col3)
      VALUES
      <cfloop from="1" to="5" index="i">
      <cfif i GT 1>,</cfif>
      (#i#,'somename','sometitle')
      </cfloop>
      </cfquery>

       

       

      tblCOM table

      ------------------

      - omID (integer auto-increment ID)

      - etc..

       

      tblProvisioning table

      ---------------------------

      - pvNum (integer auto-increment ID)

      - pvwoNum (integer foreign key from tblCOM)

      - pvType (varchar for Data or Voice)

      - pvDate (current_timestamp)