EasyCFM.COM ColdFusion Forums / Coding Help! / array output

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: array output

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

falconseye
10-20-2004 @ 2:17 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

i have an array defined as ProductID#i# which dynamically changes upon the results of the query.

on the processing page, how can i display the ProductID#i# ?

i tried
<cfloop from="1" to=".." index="i">
  <cfoutput>#FORM.ProductID#i##</cfoutput>
</cfloop>

of course, CF didnt like it. what is the correct syntax to get this output?
thanks

CJ
10-20-2004 @ 3:10 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

<cfoutput>#form['productID' & i]#</cfoutput>

-CJ-
@ #coldfusion/DALNet
http://charlie.griefer.com

falconseye
10-20-2004 @ 3:20 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

thanks CJ but i get this error

Element ProductID1 is undefined in a Java object of type class coldfusion.filter.FormScope referenced as

in the previous form i have this

<select name="ProductID[#cZ#]" size="1" class="select">
      <cfloop query="gZ">
        <option value="#ZID#" <cfif #gZ.ZID# EQ ListGetAt(#FORM.ZoneID#, #cZ#)>SELECTED</cfif>>#ProductName#</option>
      </cfloop>
     </select>

i decided to implement my version of <cfgrid>. i output a query depending on the three related selects and allow users to update these results. one of them is the product where they can pick another one from a drop down.
#cZ# is a counter, and i defined
<cfset ProductID = ArrayNew(1)>

what am i doing wrong?


falconseye
10-20-2004 @ 3:39 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

the error happens because of the way i define the select list. how can assign a value of a select list to an array's address. i.e. ProductID[3] = #FORM.ProductSelect#  without leaving that form ?

CJ
10-20-2004 @ 3:56 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Administrator
Posts: 4262
Joined: Oct 2002

you can't.  cf is server side.  the only way to get a value from the client to the server is to submit the form to the server.

-CJ-
@ #coldfusion/DALNet
http://charlie.griefer.com

falconseye
10-20-2004 @ 4:00 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

ok.
here is an example what i want to do and this is how the form looks like

productname network avails date
----------- -------- ------ -----
selectlist1 CNN 2 1/1/2000
selectlist2 TNT 2 2/1/2000
selectlist3 NBC 2 3/1/2000

the form output changes every single time depending on what user selects from the previous page. so it can be 5 rows, or it can be 25. i want to assign every select/input to an array and on the processing page update the corresponding records.
i use
<cfform action="smt" method="post">
<cfloop query="something">
<cfoutput>
....
<select name="ProductID#cZ#">
....
</select>
...
</cfloop>
</cfoutput>
</cfform>

for every field in the cfform, i had to use unique names. that's why i tried adding a counter after the select/input names.
in essence i am trying to create an updateable cfgrid. the user can change/edit any area within that output. so i have to find a way to see what has been done to the form so that i can update the necessary fields. hope it makes sense.


falconseye
10-20-2004 @ 4:36 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1033
Joined: Mar 2004

oops,

i took care of it. thanks for the help CJ

Sponsored By...
iOpenSoft, LLC is a Houston, Texas Advanced Technology Studio Specializing in Web Design, Web Development, iPhone App Development and Android App Development.