Skip to main content
Gene_Godsey
Inspiring
April 18, 2008
Question

Variables for Field Names.

  • April 18, 2008
  • 2 replies
  • 284 views
This may be a silly one for ya but I am having a brain fart now.
I am doing a dynamic form where the form questions are created fro a database.
The different field names are dynamic variables generated via itererations (++) from the database table.
The problem is that when I submit the form I need the field names as the insert or update value to populate the values statement in the query. I am having a problem locking down the actual values to use for the insert or update statement.

I will need to use a loop to iterate through the variables.
Look at the code form the form.

Thanks in advance.
Gene
    This topic has been closed for replies.

    2 replies

    April 18, 2008
    First change your form variable names to something like this:

    <cfinput type="text" name="#measure1# _#getCommInsertData.currentrow#" size="7" enabled="true" visible="true">

    adding the query name and currentrow to the end of the form name will give each input its own identity.

    Once you have done this, and submit the form, you can run a loop for the "FIELDNAMES" defined from the form to return the values
    Inspiring
    April 18, 2008
    Too much code for me to analyze.

    But see if any of these development tricks lead the way for you.

    On your action page:
    <cfdump var="#form#>

    <cfoutput>
    <cfloop collection="#form#" item="field">
    #field# = #form[field]#<br>
    </cfloop>
    <cfoutput>

    <cfoutput>
    #form.fieldNames#<br>
    <cfloop list="#form.fieldNames#" index="field">
    #field# = #form[field]#<br>
    </cfloop>
    <cfoutput>