Hi Jeff--

I am working in the direction you recommended (AND it makes sense!), and
I've received an error:

In function ListGetAt(list, index [, delimiters]), the value of index,
3, is not a valid as the first argument (this list has 2 elements).
Valid indexes are in the range 1 through the number of elements in the
list.  
  
The error occurred in
C:\Inetpub\wwwroot\blinktag\mod\comments\commentUpdate.cfm: line 14
 
12 :    UPDATE  tblComments
13 :    SET             commentPost='#ListGetAt(FORM.commentPost, j)#',
14 :                    commentActive=#ListGetAt(FORM.commentActive, j)#
15 :    WHERE   commentID=#ii#
16 : </cfquery>

I'm confused as to why I'd be getting that error when, actually, I have
3 records.  When running more tests, it's almost as if I'm losing
records--so, I'm sort of confused as to what is happening--any thoughts?



Just so you can see that my logic was somewhat in order:

Prior to trying what will forever be dubbed as "your way", I was was
pilfering an old project I was working in a different direction:

I had named my previous-page elements as
"commentPost#qCommentDisplay.CurrentRow", created a hidden form value
(FORM.commentCount) that was the RecordCount and was running the
following SQL on my update:

<CFSET iRecCount = 0>
<CFLOOP condition="iRecCount LESS THAN FORM.commentCount">
  <CFSET iRecCount = iRecCount + 1>
  <cfparam name="#FORM["commentActive" & iRecCount]#" default="0"> 
<CFQUERY DATASOURCE="blinktag">
        UPDATE  tblComments 
        SET     commentPost='#Trim(FORM["commentPost" & iRecCount])#',  
                        commentActive=#FORM["commentActive" &
iRecCount]#
        WHERE   commentID=#FORM["commentID" & iRecCount]#
</CFQUERY>
</cfloop>

That appeared to work, but none of my values had changed.

Thanks!

Russ

> -----Original Message-----
> From: Jeff Beer [mailto:[EMAIL PROTECTED] 
> Sent: Saturday, February 22, 2003 1:59 PM
> To: CF-Talk
> Subject: RE: Updating Multiple Records
> 
> 
> Hi Russ,
> 
> Assuming your field names are the same for each record, you 
> will get a list
> of data items when you submit the form, as in:
> 
> form.myId = 1,4,5,6,7
> form.firstName=jeff,tom,steve,brad,jim
> form.age=22,34,54,27,31
> 
> Now, all you need to do is loop over the myID list, and use basic list
> functions to get at the data in your form submission
> 
> <!--- initialize a loop counter --->
> <cfset j = 1>
> 
> <!--- loop over the list of record ID's in form.myID --->
> <cfloop list="#form.myId#" index="ii">
> 
>       <cfquery name="myUpdate" datasource="myDatasource">
>       UPDATE mytable
>       SET     firstName = '#ListGetAt(form.firstname, j)#',
>               age = #ListGetAt(form.age, j)#
>       WHERE myId = #ii#
>       </cfquery>
>       <!--- increment the loop counter - next time through, j 
> will equal 2, so
> the list
>               functions will grab the 2nd element in your list(s) --->
>       <cfset j = j + 1>
> 
> </cfloop>
> 
> 
> That should get you started.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to