I don't think I'd trust that approach.  It's too dependant on the way the
browser submits the form.  There's no guarantee that the 1st item in the
list #form.a# will correspond to the first item in list #form.b#, etc.
Probably most browsers _do_ work like this, but it's nearly as easy to name
the fields uniquely and handle them in your script.

I think the error you're encountering may have to do with blank fields and
the way CF processes lists.  If you have:

first comment,second comment,,fourth comment

CF will only see three list items.

I always generate unique field names:

form.userid_1
form.firstname_1
form.lastname_1
form.age_1

form.userid_2
form.firstname_2
form.lastname_2
form.age_2

form.userid_3
form.firstname_3
form.lastname_3
form.age_3


Then loop over those names in your form handler template, something like:

<cfloop index="i" from="1" to="#form.numberofrecords#">
  <cfquery datasource="#dsn#">
  UPDATE users
  SET firstname = '#Evaluate("form.firstname_#i#")#'
      lastname = '#Evaluate("form.lastname_#i#")#'
  WHERE userid = #Evaluate("form.userid_#i#")#
  </cfquery>
</cfloop>


Jim


----- Original Message -----
From: "Russ" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Saturday, February 22, 2003 1:29 PM
Subject: RE: Updating Multiple Records


> 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
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

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

Reply via email to