Solved

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

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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

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 73
Internal DNS Alias (CNAME) - two domain names to one IP address 4 81
System Analysis 5 64
WebSite Direction 1 62
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…
What You Need to Know when Searching for a Webhost Provider
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

679 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