Reference Form Fields in CFLOOP

Ask a Question related to Coldfusion - Getting Started, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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....
    4. 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...
    5. 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...
  3. #2

    Default 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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139