Solved

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

Posted on 2004-08-10
3
340 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
  • 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tomcat7  URL keeps resolving to https instead of HTTP 4 61
Coldfusion Datefield problem 2 109
SCCM vs Windows server 5 79
Public IP Address Amazon Servers 2 56
Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

777 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