Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get list of form fields submitted. 2

Status
Not open for further replies.

PTmon

IS-IT--Management
Mar 8, 2001
284
0
0
US
I have a dynamic form that I'm submitting to another "action" page. I know I saw somewhere that a list of all formfields gets passed. I think I'm going to have to loop through that list to find out the names of the formfields, so that I can update them in a sql database.
TIA,
pt

putting the "new" in "newb".....
 
Have a look at StructKeyList:
Code:
Syntax:
   StructKeyList(structure [, delimiter])

My Example:
   <cfloop list="#StructKeyList(FORM)#" index=myIndex>
      <!--- code to do stuff with the form elements --->
      <!--- FORM.#myIndex# --->
   </cfloop>
 
Thanks, DomTrix.
I was going to try and do something like:

cfloop through cgi.formfields

Then create a structure. The formfields name all begin with sel_ and then will have a intID appended dynamically.
here is the code from the form:
Code:
<select name="sel_#intID#" size="1">
  <cfloop FROM="1" To="#qryGetImage.RecordCount#" index="i">
    <option value="#i#"<cfif qryGetImage.intSortOrder IS #i#> SELECTED</cfif>>#i#</option>
</cfloop>
This is the rest of what I'm trying to do on my action page...
Code:
<cfscript>
  stSelectbox = StructNew();
    if(lower(left(strIndex, 4))) eq sel_
      StructInsert(stSelectBox, strIndex, Evaluate("sel_#strIndex#"))
</cfscript>

So I'm trying to insert all the selects with their values into a structure, then I can worry about writing the sql update statement with the structure. (structures are new to me, but seemed to be the right way to go about it.)

From what I see in structKeyList the structure has to be defined first, are the form fields automatically passed as a structure? Forgive me if this is a newbish question.
Thanks,
pt

putting the "new" in "newb".....
 
Im pretty much a newb meself and dont know about the cgi stuff so no worries.

The form structure is created and populated when the form is submitted. To see what the StructKeyList function returns, add this code in the action page for the form:

Code:
   <p>Form fields:</p> 
   <ul>
   <cfloop list="#StructKeyList(FORM)#" index="formField">      
      <li>#myIndex#</li>
   </cfloop>
   </ul>

I think you will see some other parts of the form structure but you could filter those out with the "sel_".

DT
 
rock on :)
Thanks!
pt


putting the "new" in "newb".....
 
There is also solutions as easy as
<cfdump var="#form"#>

and
<cfoutput>#form.fieldNames#</cfoutput>

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
hehe 5:30 am posting...
<cfdump var="#form#">

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top