Solved

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

Posted on 2003-12-09
4
178 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

920 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

17 Experts available now in Live!

Get 1:1 Help Now