Solved

form params don't work for formfield generated by output query

Posted on 2003-12-09
4
176 Views
Last Modified: 2013-12-24
if i leave the form.OrderID blank even though i'm using <cfparam name="form.OrderID" default=""> (i've also used default="1")

i get the error:

An error occurred while evaluating the expression:


#ListGetAt(OrderID,Counter)#

In function ListGetAt(list, index [, delimiters]) the value of index, which is 1, is not a valid index for the list given as a the first argument (this list has 0 elements). Valid indexes are in the range 1 through the number of elements in the list

my code:

<CFLOOP INDEX=Counter FROM=1 TO=#ListLen(ExAutoArtID)#>
   <CFQUERY NAME="UpdateExBuilder" DATASOURCE="Ikonltd">
       UPDATE ExBuilder
       SET OrderID=#ListGetAt(OrderID,Counter)#,
ExID=#ListGetAt(ExID,Counter)#,
AutoArtID=#ListGetAt(AutoArtID,Counter)#
       WHERE ExAutoArtID=#ListGetAt(ExAutoArtID,Counter)#
   </CFQUERY></CFLOOP>

<cfquery name="Artwork" datasource="Ikonltd">
  SELECT Title, OrderID, ExBuilder.AutoArtID,ExBuilder.ExID,ExBuilder.ExAutoArtID FROM Artwork,ExBuilder WHERE ExBuilder.ExID = #FORM.ExID#
  and Artwork.AutoArtID=ExBuilder.AutoArtID
  </cfquery>

.....................................................

 <cfoutput query="Artwork">
      <tr>
        <td valign="middle">
          <p align="right">
            <input name="OrderID" type="text" id="OrderID" size="5" value="#OrderID#"></cfoutput>
0
Comment
Question by:phillystyle123
4 Comments
 
LVL 15

Expert Comment

by:danrosenthal
ID: 9909383
What should the orderID be if the variable is blank?

See if this helps:
<CFIF LISTLEN(orderID) gte counter>#ListGetAt(OrderID,Counter)#<CFELSE>NULL</CFIF>
0
 
LVL 17

Expert Comment

by:Tacobell777
ID: 9909429
basically it is saying the value of variable "Counter" is not a valid index, i.e. its probably not an integer.

#ListGetAt("item1, item2, item3", 2)# this is what the function would look like if parsed, maybe that clears things up?
0
 
LVL 17

Expert Comment

by:anandkp
ID: 9910004
If u use
<cfparam name="OrderID" default="">
& in ur code below
#ListGetAt(OrderID,Counter)#

u r bound to get an error ! as u cannot use listgetat on a empty list !

u will need to chk if its blank or not or set it to some value.

i also see that u r running a loop & using counter to get the respective element from teh list
i hope ur list has all the elements ...

if not - u wld be better of checking - the length of the OrderID to be equal to ExAutoArtID [based on ur code]

I guess the logic has gone wrong here ... or may be u cld tell us what exactly is going on - so as to get a clear idea on what cld be done !

K'Rgds
Anand
0
 
LVL 11

Accepted Solution

by:
hart earned 100 total points
ID: 9910183
<CFLOOP INDEX=Counter FROM=1 TO=#ListLen(ExAutoArtID)#>
  <CFQUERY NAME="UpdateExBuilder" DATASOURCE="Ikonltd">
      UPDATE ExBuilder
      SET ExID=#ListGetAt(ExID,Counter)#,
      <cfif ListLen(OrderID) Gte Counter>
      OrderID=#ListGetAt(OrderID,Counter)#,
      </cfif>
      AutoArtID=#ListGetAt(AutoArtID,Counter)#
      WHERE ExAutoArtID=#ListGetAt(ExAutoArtID,Counter)#
  </CFQUERY>
</CFLOOP>

Regards
Hart
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Article by: kevp75
Hey folks, 'bout time for me to come around with a little tip. Thanks to IIS 7.5 Extensions and Microsoft (well... really Windows 8, and IIS 8 I guess...), we can now prime our Application Pools, when IIS starts. Now, though it would be nice t…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now