Solved

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

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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now