Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<<arrgghh!!>>concat/cfform/variable problem (?)

Status
Not open for further replies.

dzr

Programmer
Nov 20, 2001
109
US
New at cold fusion (as you will soon see).
I'm making a view/edit page for a weekly report. It's broken down by day and their choice of activites for each day are exactly the same as for any other day. The field names in the db are like mon_contact, tue_contact...
I want a loop to send it through to name the variables. I have an include that sets up the form with variables with the base fieldname w/out day -- "#contact#" but can't seem to find an easy way to change all the fields names to have the day at the beginning.


->Here's what i have now:

<cfquery name=&quot;getreport&quot; datasource=&quot;datasourcename&quot;>
select * from ... where reportkey=#reportkey#
</cfquery>
<cfoutput>MONDAY:<br></cfoutput>
<cfset contact=&quot;mon_contact&quot;>
<cfset contact_out=&quot;#getreport.mon_contact#&quot;>
<cfinclude template=&quot;inc_daily.cfm&quot;>

->and in inc_daily.cfm
<td align='center'>
<cfinput type='text' size=5 name='#contact#' value='#contact_out#'></td>
</td>

I have to do the cfset for about 25 variables before I include the inc-daily and then do it again for tue and wed...all 7 days!

What I have works but is so awfully messy I can't look at it! The real frustrating part is that I can do it in php in one loop easy (which doesn't help of course - CF doesn't seem to like it when you put a $ in front of variables)
My suggestion to the client was a daily report as this is the logical way to do it anyway but...customer is always right yes?

please help!
(if you can translate what i'm talking about)

 
Try something like

<cfloop list=&quot;Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday&quot; index=&quot;day&quot;>
<cfset contact = &quot;#day#_contact&quot;>
<cfset contact_out = Evaluate(&quot;getreport.#day#_contact&quot;)>
</cfloop>
 
bless you! :-D

You just helped me turn 355 lines of code into 50!

(i would have been so humiliated if i published that code)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top