I have a form with several values (about 25 fields). After posting the form and putting it into the database, I have to get information about the form and send it to the report. The report should show only fields with people who have the value (hence the report will contain only 5 fields, if only 5 fields are filled).
The easiest way would be to do something like this:
& lt; Cfif form.firstname neq & gt; & Lt; Li & gt; & Lt; First name: # FORM.FIRSTNAME # & lt; / Li & gt; & Lt; / Cfif> & Lt; Cfif form.lastname neq & gt; & Lt; Li & gt; & Lt; Last name: # FORM.LASTNAME # & lt; / Li & gt; & Lt; / Cfif> Can someone recommend a better way of doing this? I would like to keep it on the Coldfusion side, because the full report has been stripped to prepare a plain text report in the pseudonym form of HTML.
You can loop by them like this
Lt; Cfloop list = "# form.fieldNames #" index = "i" & gt; & Lt; Li & gt; & Lt; Cfoutput & gt; # I # = # form [i] # & lt; / Cfoutput & gt; & Lt; / Li & gt; & Lt; / Cfloop & gt; Not sure what exactly you want, but it can get you on the right track
based on your comment Try it: & lt; Cfloop list = "# form.fieldNames #" index = "i" & gt; & Lt; Li & gt; & Lt; Cfoutput & gt; & Lt; Cfswitch expression = "# i #" & gt; & Lt; Cfcase value = "first name" & gt; First name & lt; / Cfcase & gt; & Lt; Cfcase value = "last name" & gt; Last name & lt; / Cfcase & gt; & Lt; Cfdefaultcase & gt; # I # & lt; / Cfdefaultcase & gt; & Lt; / Cfswitch & gt; : #forms [i] # & lt; / Cfoutput & gt; & Lt; / Li & gt; & Lt; / Cfloop & gt;
No comments:
Post a Comment