Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

Contributor ,
Apr 22, 2014 Apr 22, 2014

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)

250
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources