ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old December 5th, 2003, 01:11 PM
fricknoutstandi fricknoutstandi is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: washington DC
Posts: 1 fricknoutstandi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Dynamic datasource and table name Help..

I'm new to CF and trying to populate a page with 75 editable user fields. Each of the fields are related to one of as many as 15 database (SQL) tables.

The project requires edit capabililties without reloading the page, so using DIV tags to SHOW and HIDE the edit page is my strategy there. By the time I add buttons and formatting, it's around 100 lines of code PER user field.. or 7,500 lines of code total.

Instead of brute code, i'd like to loop the process. I've created a new table (table1) that has similar properties between the 75 user fields. Two fields in Table1 are the datasource location (datasource) and the table name (tablename) for the userfield values.

My problem is HOW do I put these variables into the cfif statement's attributes and display thevalues of the field if it is present?



Static:
<DIV class="show" ID="field1">

<cfif #datasourceA.tablenameA# EQ ''>
#table1.Description#

<cfelse>
#datasourceA.tablenameA#

</cfif>
</DIV>

<DIV class="show" ID="field1">

<cfif #datasourceB.tablenameB# EQ ''>
#table1.Description#

<cfelse>
#datasourceB.tablenameB#

</cfif>
</DIV>



Dynamic (Doesnt work):
<DIV class="show" ID="field1">

<cfif #table1.datasource#.#table1.tablename# EQ ''>
#table1.Description#

<cfelse>
##table1.datasource#.#table1.tablename##

</cfif>
</DIV>

Thanks from a very frustrated and confused newber!
Fricknout

Last edited by fricknoutstandi : December 8th, 2003 at 08:33 AM.

Reply With Quote
  #2  
Old December 8th, 2003, 08:12 AM
kiteless kiteless is offline
Moderator
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Jun 2002
Location: Raleigh, NC
Posts: 3,618 kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level)kiteless User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 9 h 44 m 33 sec
Reputation Power: 53
You want the evaluate() function:

<cfif evaluate( '#table1.datasource#.#table1.tablename#' ) EQ ''>

Be careful though, evaluate() is a hog and using it too much will probably slow things down. But if it's the only way to do what you need to, sometimes that's the price you have to pay.

You might consider using custom tags, user defined functions, or CFC object instances to do this more efficiently (ie not such a long file) in the future.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Dynamic datasource and table name Help..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway