Solved

Creating Dynamic Form Fields.

Posted on 2003-12-06
4
192 Views
Last Modified: 2013-12-24
I Have a form inserting form fields into a SQL table

Insert Into Table_Name
(Sort, Display_Name, Field_Script)
Values
('1', 'Field One', '<input type="text" name="Field_One" value"##item_details.item_name##">')


That all works Fine...

Next I have a page that displays all records in the table in order to create a form page..

<cfset tablename=url.program>

<cfquery name="fields" datasource="dsn">
SELECT *
FROM [#tablename#]
Order by sort
</cfquery>

Then I want to output all records into dynamic form...

<form action="item_details.cfm">
      <tr>
<cfoutput query="fields">
            <td width="80">#fields.Display_Name#</td>
            <td width="50">#fields.Field_script#</td>
<cfif fields.currentrow mod 2 eq 0>
</tr><tr>
</cfif>
</cfoutput>
</tr>
</form>

My problem is when the page is viewed I am getting the #item_details.item_name# variable inside the text field.
It is as if Cold Fusion parses it once to get the data out of the database (the form field is visible and named correctly)
but the value come up as the variable its self.

I have tried the evaluate function with no luck.

<form action="item_details.cfm">
      <tr>
<cfoutput query="fields">
            <td width="80">#fields.Display_Name#</td>
            <td width="50">#evaluate("fields.Field_script")#</td>
<cfif fields.currentrow mod 2 eq 0>
</tr><tr>
</cfif>
</cfoutput>
</tr>
</form>

Please Help I need a fix or a work around for this.   Thanks in Advance

Joe
0
Comment
Question by:joebox
  • 3
4 Comments
 
LVL 17

Accepted Solution

by:
anandkp earned 500 total points
Comment Utility
try - #evaluate(de('fields.Field_script'))#

it shld work for u !

K'Rgds
Anand
0
 
LVL 17

Expert Comment

by:anandkp
Comment Utility
thou after looking in closely - i wonder what are u trying to achieve ?
i mean why wld u wanna have a form element inside ur DB ? & from where do u plan to get the value "item_details.item_name" ? as at run time - u dont have a query with this name ...

just asking - as i got confused with ur logic / flow

let me know ...
0
 

Author Comment

by:joebox
Comment Utility
Basically what i am trying to do is create a form that has static values of input fields.  Then the user can choose what type of fields they want to add to to a database. After the submit, it directs them to a page that has a cfquery on it that pulls all fields from the databse onto a dynamic form.  This would let the user add as many fields to the dynamic form page as they want.  Of course the <cfinput> tags are great for this because I wont have to change any sql for the insert or update.


anandkp your answer was in the right direction as it returned fields.field_script as the value of the text field.  I removed the '  ' and it worked fine.  Thanks for the help..  This place is great!!!  Joe
0
 
LVL 17

Expert Comment

by:anandkp
Comment Utility
yeah - the single quotes shldnt have been there ! my apologies for the typo error !

gr8 going !

Cheers
Anand
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now