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
Solved

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

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

Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

Question has a verified solution.

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

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
When it comes to showing a 404 error page to your visitors, you do not want that generic page to show, and you especially do not want your hosting provider’s ad error page to show either. In this article, I will show you how to enable the custom 40…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

837 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