• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

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

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
phillystyle123
Asked:
phillystyle123
1 Solution
 
danrosenthalCommented:
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
 
Tacobell777Commented:
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
 
anandkpCommented:
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
 
hartCommented:
<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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now