Soo close. Looping over certian form elements to see if they are empty
I have a form that gets split into 2 actions. Part is emailed, part is databased. Didn't think of it at the time, since the part of the form is shared, no matter if the parts that are databased are empty, it still gets inserted. What I need to do is check about 11 fields to see if they are blank. If not, then do an insert, if so, then don't do anything.
What I thought would work best was create an array of the fields that I wanted checked. Then loop over the form.(element) and see if it is not blank. If it isn't, then do the insert and stop checking. I tried this, but am getting errors. Any ideas? Would one long cfif statement with a bunch of OR's be better?
<cfset ffields = ArrayNew(1) />
<cfset ffields[12] = "degree" />
<cfset ffields[1] = "title" />
<cfset ffields[2] = "dept2" />
<cfset ffields[3] = "spec" />
<cfset ffields[4] = "location" />
<cfset ffields[5] = "addr" />
<cfset ffields[6] = "city" />
<cfset ffields[7] = "zip" />
<cfset ffields[8] = "phone" />
<cfset ffields[9] = "medschool" />
<cfset ffields[10] = "baordcerts" />
<cfset ffields[11] = "otherChanges" />
<cfloop index="x" from="1" to="#arrayLen(ffields)#">
<cfset fname = #ffields
<cfif form.#fname# NEQ "">
Do and insert
<cfbreak />
</cfif>
</cfloop>
