Erica,
This should do what you want:
UPDATE interview
SET ivr_key = '#Evaluate("form.fieldname" & counter)#'
WHERE ...
Nelson
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Wednesday, August 29, 2001 6:44 PM
Subject: Dynamic Fieldnames & database update
>
> I am working on a dynamic form that allows me to update multiple records
at
> once.
> We use the primary key from the table as a hidden field to identify the
> record, and append a unique number to all fields from each record via a
> counter.
> For example, the form would look something like this
> <cfloop>
> < input key#counter#> < input fieldname#counter#> < input
fieldname#counter#>
> </cfloop>
>
> Problem is, when we go to update the database, how do we specify the
> formfields? I'd assumed that we would need to loop over our counter
again,
> but I don't know how to make the dynamic fieldnames in the update. How do
I
> get coldfusion to recognize that I want #form.fieldname1# not
> "form.fieldname1" and not "value of fieldname1" the first time I loop over
> something like
> UPDATE interview
> SET ivr_key = '#form.fieldname##counter#'
>
> Any help would be appreciated!
>
>
> Here's the form so far:
> <cfoutput>
> <cfquery name="getinterviewdata" datasource="dsrc">
> SELECT *
> FROM interview INNER JOIN interviewer on interview.ivr_key =
> interviewer.ivr_key
> WHERE interview.ivr_key = #cookie.interviewerid#
> AND sch_name = '#cookie.schoolsession#'
> </cfquery>
> </cfoutput>
>
> <CFQUERY name="getivrs" datasource="dsrc">
> SELECT *
> FROM Interviewer
> </cfquery>
>
>
> <table>
> <tr>
> <td><font face="Verdana" size="-1">Scheduled Interviews for
> <cfoutput>#getinterviewdata.ivr_firstname#
> #getinterviewdata.ivr_lastname#</cfoutput></font><br>
> <HR></td>
> </tr>
> </table>
>
> <form name="UpdatedInterviewData" action="interviewedit_action.cfm" method
> ="post">
> <table cellspacing="0" cellpadding="0" width="90%">
> <tr>
> <td>
> <table border="1" bordercolor="Gray" cellspacing="0"
> cellpadding="0">
> <tr bgcolor="#FFFF80">
> <th width="20%">Interviewer</th>
> <th width="15%">Start Time</th>
> <th width="15%">End Time</th>
> <th width="15%">Location</th>
> </tr>
> <CFPARAM name="counter" default="0">
> <CFLOOP query="getinterviewdata">
> <tr>
> <CFSET counter = counter+1>
> <td align="center">
> <select name="InterviewChange<cfoutput>
> #counter#</cfoutput>">
> <cfoutput query="getivrs">
> <option value="
> #getivrs.ivr_key#" <cfif isdefined("cookie.InterviewerID") and
> cookie.InterviewerID eq GetIvrs.ivr_key>selected</cfif>>
> #getivrs.ivr_FirstName# #getivrs.ivr_LastName#</option>
> </cfoutput>
> </select>
> </td>
> <cfoutput>
> <td width="15%" align="center">
> #TimeFormat(getinterviewdata.int_StartTime, 'hh:mm tt')#</td>
> <td width="15%" align="center">
> #TimeFormat(getinterviewdata.int_EndTime, 'hh:mm tt')#</td>
> <td width="15%" align="center">
> #getinterviewdata.loc_Name#</td>
> <input type="hidden"
name="intkey#counter#"
> value="#getinterviewdata.int_Code#">
> </cfoutput>
> </tr>
> </cfloop>
> <input type="hidden" name="counterfield" value
> ="<cfoutput>#counter#</cfoutput>">
> </table>
> </td>
> </tr>
>
> </table>
> <table>
> <tr>
> <td><INPUT TYPE="submit" NAME="Submit" Value="Submit"></td>
> <td><INPUT TYPE="reset" NAME="ResetForm"
Value="Reset"></td>
> </tr>
> </table>
> </form>
>
>
>
>
> Thanks!
> Erica
>
>
> Erica Vitina
> Web Developer
> Abbott Laboratories
> [EMAIL PROTECTED]
>
>
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists