Ask a Question related to Coldfusion - Getting Started, Design and Development.
-
ccap2 #1
Reference Form Fields in CFLOOP
Ok, I admit...up until yesterday I had only heard of ColdFusion and never used
it. But my boss gave me an assignment due tomorrow and I'm desperately trying
to get it done. Yes, it's a perfect Dilbert scenario.
Basically, I have a form displaying multiple records and the user makes all
the changes to the records and the presses the "process updates" button. I
basically need to loop through the records and process them, but I guess I
can't figure what I'm doing wrong with syntax for the CFLOOP. Here is what
I've done so far:
------------- here is my form that gets the recordcount so I can loop through
it (appears to work). -----------------------
<form name="UpdateForm" action="salupdate.cfm" method="post">
<CFOUTPUT QUERY="getsaldet" GROUP="entry_id">
Insert bunch of table formatting and data output here.
</CFOUTPUT>
<input type="text" name="RowCount"
value="<cfoutput>#getsaldet.RecordCount#</cfoutput>">
</form>
--------------Then I try to do the CFLOOP to process the
records.---------------------
<cfloop index="x" from="1" to="#UpdateForm.RowCount#">
<cfquery datasource="salsurvey2005">
UPDATE ccapdet SET
county = #UpdateForm["county"]#,
category = #UpdateForm["category_" & x]#,
position = #UpdateForm["position_" & x]#,
hours = #UpdateForm["hours_" & x]# ,
hrs_oth = #UpdateForm["hrs_oth_" & x]#,
ft_emp = #UpdateForm["ft_emp_" & x]#,
ft_low = #UpdateForm["ft_low_" & x]#,
ft_high = #UpdateForm["ft_high_" & x]#,
ft_yrs = #UpdateForm["ft_yrs_" & x]#,
pt_emp = #UpdateForm["pt_emp_" & x]#,
pt_low = #UpdateForm["pt_low_" & x]#,
pt_high = #UpdateForm["pt_high_" & x]#,
pt_yrs = #UpdateForm["pt_yrs_" & x]#,
pt_type = #UpdateForm["pt_type_" & x]#,
ft_type = #UpdateForm["ft_type_" & x]#,
date_mod = #UpdateForm["date_mod"]#
WHERE entry_id = #UpdateForm["entry_id_" & x]#
</cfquery>
</cfloop>
My guess is that I'm not referencing the form right or I just don't know the
syntax. Sorry for being such a noob, but I've tried numerous variations and I
haven't come up with anything. Thanks for any help.
ccap2 Guest
-
using cfloop to cycle through database fields
I have the results of a survey stored in a database, in fields named Q1 through Q29. I need to cycle through each field and determine the value in... -
CFloop through Form results
I'm trying to set a value of 1 or 0 if any Radio on a form submission (loop) is labeled 'OutofService'. The form is looped by Radio_ID. The... -
cfloop and extracting info from fields
Hi I am trying to extract information from an old database into a newer one, and I have a problem that I have been trying to solve for a while.... -
CFLOOP & Form input
Try looping through the GetJobs query like this: <cfloop from="1" to="#GetJobs.recordcount#" index="i"> <!---To read the data in GetJobs... -
Have two fields reference the same field
Hello, I am trying to have two fields (ISBN) and (Product ID) reference the same field (ISBN without dashes) in another table to retrieve the... -
jdeline #2
Re: Reference Form Fields in CFLOOP
You can simplify your UPDATE statement and probably solve your problem at the
same time. See code below. Note the single quotes on non-numeric data. If
entry_id in the WHERE clause is numeric, remove the single quotes from the
value.
<cfloop index="x" from="1" to="#UpdateForm.RowCount#">
<cfquery datasource="salsurvey2005">
UPDATE ccapdet SET
county = '#county#',
category = '#category#',
position = '#position#',
etc.
WHERE entry_id = '#entry_id#'
</cfquery>
</cfloop>
jdeline Guest



Reply With Quote

