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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ignore Hidden formfields in Loop??? 1

Status
Not open for further replies.

megaladon

Programmer
Sep 27, 2002
14
CA
I am trying to insert the information from a form into a database, but I do not want the Hidden formfield values passed to the db. This script will be used for multiple forms, so I have to Loop through the formfields ignoring the Hidden formfields?? This is what I have so far.

<cfif isdefined(&quot;Form.Submit&quot;)>
<cfset Field_List = &quot;&quot;>
<cfloop index=&quot;Field_Name&quot; list=&quot;#Form.Fieldnames#&quot;>
<cfset Field_List = listappend(Field_List,Field_Name)>
</cfloop>

<CFUPDATE DATASOURCE=&quot;EKG&quot;
TABLENAME=&quot;#Form.TableName#&quot;
FORMFIELDS=&quot;#Field_List#&quot;>
</cfif>

Thanks

 
Prefix each hidden field with something.. let's say h..

Now you can use:

Code:
<cfif isdefined(&quot;Form.Submit&quot;)>
<cfset Field_List = &quot;&quot;>
  <cfloop index=&quot;Field_Name&quot;  list=&quot;#Form.Fieldnames#&quot;>
    <CFIF left(Field_Name,1) is not &quot;h&quot;>
     <cfset Field_List = listappend(Field_List,Field_Name)>
    </CFIF>
  </cfloop> 
  
  <CFUPDATE DATASOURCE=&quot;EKG&quot;
             TABLENAME=&quot;#Form.TableName#&quot;
            FORMFIELDS=&quot;#Field_List#&quot;>  
</cfif>
Did I help?
Vote!
 
Mind clicking the &quot;Mark this post as a helpful/expert post!&quot; link? :) Did I help?
Vote!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top