Solved

How to loop over all form fields, setting blank fields to "Null"

Posted on 2004-08-10
3
361 Views
Last Modified: 2013-12-24
So far I have this:

<cfloop collection="#Form#" item="ThisField">
  <cfif len(form[ThisField]) LT 1>
    <cfoutput>
        #ThisField# is blank<br>
    </cfoutput>
  <cfelse>
    <cfoutput>
      #ThisField# is populated<br>
    </cfoutput>
  </cfif>
</cfloop>

Which outputs the field name and if populated or blank.

How can I set the VALUE of each blank field to "NUll" or "EMPTY" or anything?

Should I be using a list?
0
Comment
Question by:SDtubeone
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
danrosenthal earned 500 total points
ID: 11765562
This should do it:

<CFLOOP LIST="#form.fieldnames#" Index="field">
<CFIF len(evaluate('form.'&field)) eq 0>
  <CFSET 'form.#field#' = "NULL">
  #field# value is NULL<BR>
<CFELSE>
  #field# value is #evaluate(field)#
</CFIF>
</CFLOOP>
0
 

Author Comment

by:SDtubeone
ID: 11766044
#field# value is NULL
#field# value is #evaluate(field)#

This is the output I get...Am I missing something?
0
 

Author Comment

by:SDtubeone
ID: 11766122
Oh...Just my CFOUTPUT tages...

Thanks very much...

Cheers,

Paul
0

Featured Post

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question