|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > Dynamic datasource and table name Help.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|