EasyCFM.COM ColdFusion Forums / Coding Help! / update selected rows from

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: update selected rows from

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

egiblock
11-09-2012 @ 9:07 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 214
Joined: Mar 2003

i have a table that displays a name, amount, and a checkbox:


<form action="update_paid.cfm" method="post">
....

<tr>
<td><input type="hidden" name="id_#currentrow#" value="#numberformat(UniqueID,'99999999999999')#">#numberformat(UniqueID,'99999999999999')#</td>
<td>#family#</td>
<td>#numberformat(total,'9,999.99')#</td>
<td><input type="checkbox" name="pmt_#currentrow#" id="pmt_#currentrow#"></td>
</tr>

<input type="hidden" name="numberOfFields" value="#GetRecvReport.RecordCount#">
....
</form>


i want it to loop through only the records that have the checkbox checked and then update the main table.  

in just testing the loop to make sure the right things are going to get updated:


<cfparam name="form.numberOfFields" default="0">
<cfloop from="1" to="#form.numberOfFields#" index="counter">
<cfset UniqueID = FORM["id_"& counter]>
<cfset YesToUpdate = FORM["pmt_"& counter]>

<cfif (YesToUpdate IS 1)
     <cfoutput>

     #uniqueid# - #YesToUpdate#<br>
     </cfoutput>
</cfif>

</cfloop>


i get an error message from my local cf10 development server



HTTP Status 400 - POST parameters exceeds the maximum limit.

type Status report

message POST parameters exceeds the maximum limit.

description The request sent by the client was syntactically incorrect (POST parameters exceeds the maximum limit.).
Apache Tomcat/7.0.23


is this a code or server issue ?  I'm running WAMP with CF10dev.


..E

Webmaster
11-09-2012 @ 9:26 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4542
Joined: Jan 2002

you are over complicating it.

<input type="checkbox" name="selectedItem" value="#id#"
/>

name all of the checkboxes the same thing.. then on
your "action" page... you will have "1" variable:

form.selectedItem

that will contain all the "selected" ids.. so if you
picked, 3, 8, and 12..

form.selectedItem = "3,8,12";

You can then loop through that:

<cfloop list="#form.selectedItem#" index="i" />

   #i# will hold each individual value...

</cfloop>

doe that make sense?

Pablo Varando
Senior Application Architect
EasyCFM.COM, LLC.

904.483.1457 \\ mobile
webmaster@easycfm.com \\email

\m/ (>.<) \m/
--- rock on ---

cfSearchin
11-10-2012 @ 7:18 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 608
Joined: Feb 2008

quote:

HTTP Status 400 - POST parameters exceeds the maximum limit.


They added a limit to the maximum POST parameters to prevent hash collision attacks. You can adjust that setting in your server configuration.
http://www.cutterscrossing.com/index.cfm/2012/3/27/ColdFusion-Security-Hotfix-and-Big-Forms

quote:

I want it to loop through only the records that have the checkbox checked and then update the main table.


With what values? If you are simply updating all records with the same value, then I agree with Pablo. Give the checkboxes the same name and use an IN (...) clause instead of a loop.


UPDATE SomeTable
SET    SomeColumn = 'yes'
WHERE  RecordID IN (
        <cfqueryparam value="#form.checkBoxName#"
              cfsqltype="...your type here .."
              list="true">

       )


However, if you are updating each record with  different values, I would stick with your current approach.

This message was edited by cfSearchin on 11-10-12 @ 7:21 AM

egiblock
11-10-2012 @ 5:16 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 214
Joined: Mar 2003

Sounds like a plan.  I'll try it tomorrow or the next
and let ya know if it works for me Smile  

..E


Website Designed and Developed by Pablo Varando.