Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Lease-to-own eliminates the expenditure of hardware replacement and allows you to pay off the server over time. Usually, this is much cheaper than leasing servers. Think of lease-to-own as credit without interest.

838 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