Accessing Form Variables

We have a client that is posting to a cfc using jquery.   These are the form fields that we are getting from them

PORTLET_ORDERS[0][COLUMN]=0
PORTLET_ORDERS[0][ID]=panel_id_1
PORTLET_ORDERS[0][ROW]=0
PORTLET_ORDERS[1][COLUMN]=1
PORTLET_ORDERS[1][ID]=panel_id_2
PORTLET_ORDERS[1][ROW]=0
PORTLET_ORDERS[2][COLUMN]=1
PORTLET_ORDERS[2][ID]=panel_id_3
PORTLET_ORDERS[2][ROW]=1
PORTLET_ORDERS[3][COLUMN]=1
PORTLET_ORDERS[3][ID]=panel_id_4
PORTLET_ORDERS[3][ROW]=2

Open in new window


I feel like I am being stupid but if I want to get the column, id and row for PORTLET_ORDERS[3], how do I do that?   Something as simple as #evaluate("FORM.PORTLET_ORDERS[" & xx & "][ID]")# where xx is a cfloop index doesn't work - it says ID isn't defined which I get.
digitalwiseAsked:
Who is Participating?
 
gdemariaCommented:
Never need to use evaluate...

Not sure what you are asking if it is beyond just the syntax....

this looks like an array of structures?   Except CF doesn't have a 0 element for an array, maybe start at 1?

<cfset theVAlue = FORM.PORTLET_ORDERS[0]["COLUMN"]>
0
 
digitalwiseAuthor Commented:
So I did <cfset theVAlue = FORM.PORTLET_ORDERS[0]["ID"]>

This is the error I get from that:

Element PORTLET_ORDERS is undefined in a Java object of type class [Ljava.lang.String;.

Open in new window


This is the jquery that is posting

$("#draggable_portlets").sortable({
                connectWith: ".panel",
                items: ".panel",
                opacity: 0.8,
                coneHelperSize: true,
                placeholder: 'sortable-box-placeholder round-all',
                forcePlaceholderSize: true,
                tolerance: "pointer",
								update: function( event, ui ) {
									portlet_order = $("#draggable_portlets .panel").map(function() { 
									  return {
											id: this.id, 
											column: $(this).closest(".column").index(), 
											row: $(this).index() 
										}
									}).get();
									
									//console.log(ids_order);
									 
									$.post(
										"portlet_update.cfm", 
										{
											portlet_orders: portlet_order
										},
										function(data, textStatus, jqXHR) {
											console.log("success");
											console.log(data);
										})
							  },
            });

Open in new window


What I provided is the actual list of form fields/values that are being sent to the cfc.

FIELDNAMES=PORTLET_ORDERS[0][ID],PORTLET_ORDERS[0][COLUMN],PORTLET_ORDERS[0][ROW],PORTLET_ORDERS[1][ID],PORTLET_ORDERS[1][COLUMN],PORTLET_ORDERS[1][ROW],PORTLET_ORDERS[2][ID],PORTLET_ORDERS[2][COLUMN],PORTLET_ORDERS[2][ROW],PORTLET_ORDERS[3][ID],PORTLET_ORDERS[3][COLUMN],PORTLET_ORDERS[3][ROW]
0
 
gdemariaCommented:
I don't see a cfc, but if your code is inside a cfc function and the values are passed to it, then you should be checking the arguments scope

If this code is in side that  file  portlet_update.cfm, it looks like it is sending via GET, so the scope would be URL and not FORM.

You can dump the various scopes to see what values you have

<dump var="#url#">
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
digitalwiseAuthor Commented:
The code is inside a .js file.  They are definitely form variables.   If i do <CFSET LenPortals = #listlen(form.fieldnames)# / 3> - that works.  I just can't reference any of the fields.    What I posted first are the form fields and their values that show up.   The interesting thing is if I do a cfdump="#form#" - nothing shows up...  But I can see the form fields in the debugging output.  

Form Fields:
FIELDNAMES=PORTLET_ORDERS[0][ID],PORTLET_ORDERS[0][COLUMN],PORTLET_ORDERS[0][ROW],PORTLET_ORDERS[1][ID],PORTLET_ORDERS[1][COLUMN],PORTLET_ORDERS[1][ROW],PORTLET_ORDERS[2][ID],PORTLET_ORDERS[2][COLUMN],PORTLET_ORDERS[2][ROW],PORTLET_ORDERS[3][ID],PORTLET_ORDERS[3][COLUMN],PORTLET_ORDERS[3][ROW]
PORTLET_ORDERS[0][COLUMN]=0
PORTLET_ORDERS[0][ID]=panel_id_1
PORTLET_ORDERS[0][ROW]=0
PORTLET_ORDERS[1][COLUMN]=1
PORTLET_ORDERS[1][ID]=panel_id_2
PORTLET_ORDERS[1][ROW]=0
PORTLET_ORDERS[2][COLUMN]=1
PORTLET_ORDERS[2][ID]=panel_id_3
PORTLET_ORDERS[2][ROW]=1
PORTLET_ORDERS[3][COLUMN]=1
PORTLET_ORDERS[3][ID]=panel_id_4
PORTLET_ORDERS[3][ROW]=2

Open in new window

0
 
digitalwiseAuthor Commented:
This didn't really help but you can have the points.  I figured it out.
0
 
gdemariaCommented:
You should post the solution for others who maybe reading along, or see it in the future
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.