Submit a cfgrid to the session!

The challenge with using cfgrid, is that it doesnt exist in the form in nothing was changed…. here is a script that runs through the grid, and gets the values and puts them in the form scope… You can use this to submit to the session, or another scope of some sort. The code is based on another great site! asfusion, fantastic examples, and they are how i got knowledgable of the subject.

View the example

asfusion Looping over records of a large gridI slightly modified thier code

<cfif isDefined(‘form’)>

<cfdump var=“#form#”>


<!— replace this cfscript by your query: <cfquery name=“products”> —>


//generate a large query

products = queryNew(“”);

names = “”;

prices = “”;

for (i = 1; i LTE 25; i = i + 1){

names = listappend(names,“Product “ & i,“,”);

prices = listappend(prices,100 + i,“,”);





<cfsavecontent variable=“changePrice”>

var i = 0;

updateBtn.enabled = false;

//make the loop with onEnterFrame instead of a “for”

_root.onEnterFrame = function ()


if(i < productsGrid.length) {

//do one iteration of the loop




else {

//end the loop

_root.onEnterFrame = undefined;

updateBtn.enabled = true;



//the function that does whatever we need in each iteration

_root.updatePrice = function (index){

productsGrid.editField(index, ‘price’, Number(productsGrid.getItemAt(index)[‘price’]));

productsGrid.setPropertiesAt(index, {backgroundColor:0xF7FFB7});



<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”“> <html>


<meta http-equiv=“Content-Type” content=“text/html; charset=iso-8859-1”>

<title>Looping over a large cfgrid</title>


<body >

<cfform name=“myForm” format=“flash” width=“350” height=“250”>

<cfformitem type=“text”>Click Update then submit the form.</cfformitem>

<cfformgroup type=“vBox”>

<cfgrid name= “productsGrid” query=“products” height=“150” rowheaders=“false”>

Page 1 of 2 | Next page