Skip to main content
Inspiring
April 22, 2014
Question

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

  • April 22, 2014
  • 0 replies
  • 270 views

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

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)

This topic has been closed for replies.