User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the ColdFusion section within the Web Development category of DaniWeb, a massive community of 426,256 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,117 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ColdFusion advertiser: Programming Forums

coldfusion - save edited query results

Join Date: Jul 2005
Location: Downingtown
Posts: 58
Reputation: hinde is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 3
hinde hinde is offline Offline
Junior Poster in Training

Tutorial Re: coldfusion - save edited query results

  #2  
Mar 16th, 2008
Please post what you have so far, and I will take a look at it.

Regardless, I have some tips for you. From what I gather from your original post, you are trying to retrieve and present a variable number of records in forms that allow for a user to modify the data. In the past, when I have to deal with issues like this, I will usually have one cfoutput tag that loops over the records your query returned, with a hidden field that is outside the cfoutput containing the ids of the records in a comma-delimited format (name it queryIDs). The loop will present the data in a form as you have already said you are able to do, and you will simply have the names of the field contain the unique identifier of the record (eg. firstName_#qryMyQuery.uniqueID#). On the action page of the form you will use a cfloop to loop over the list of ids from your hidden field on the form page. Inside the loop you will then perform the database action you need to perform. You can see what I mean below:
<cfloop list="#FORM.queryIDs#" index="recordID">
    <cfquery name="INSERT" datasource="myDatasource">
    Insert Into Table2 (Table2ID, Table1ID, FirstName, LastName, ...)
    Values (#newRecordID#,
        #recordID#
        '#Evaluate("FORM.FirstName_#recordID#")#',
        '#Evaluate("FORM.LastName_#recordID#")#',
        ...)
    </cfquery>
</cfloop>
You will of course need to determine the value of newRecordID on your own. What makes this possible is the Evaluate Function (read up on it at Adobe's Livedocs). The evaluate function receives a string and dynamically returns the value of the string. In this case you are asking it to return the value of FORM.FirstName_1 (or whatever the value of recordID is).

Note: One thing that you should be aware of is that you should never start the name of a form field with a number. It tends to not work (at least it didn't work the last time I tried it).
Last edited by hinde : Mar 16th, 2008 at 10:18 pm. Reason: Edited to add quoted around what are almost certainly form fields containing text. I swear to god that gets me every damn time.
Reply With Quote  
All times are GMT -4. The time now is 9:10 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC