#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Location
    washington DC
    Posts
    1
    Rep 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.
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,265
    Rep Power
    968
    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.

IMN logo majestic logo threadwatch logo seochat tools logo