Solved

Coldfusion retrieve dynamic values

Posted on 2016-10-04
1
41 Views
Last Modified: 2016-10-04
I am using Jquery to produce dynamic text fields. The result of the form is as per the below.

How can I retrieve the content of myText[] for each field using Coldfusion?

<form method="post" action="collect_vals.cfm">
<div class="input_fields_wrap">
    <button class="add_field_button">Add More Fields</button>
    <div><input type="text" name="mytext[]"></div>
    <div><input type="text" name="mytext[]"></div>
    <div><input type="text" name="mytext[]"></div>
    <div><input type="text" name="mytext[]"></div>
    <div><input type="text" name="mytext[]"></div>
</div>
</form>
0
Comment
Question by:Errol Farro
1 Comment
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 41828715
When the form is submitted, the text input value is found in a variable of the form:

    form.myText

where myText is the name of the input field.

You cannot have brackets [] as part of your text input field's name.

Assuming the bracket is a sequential number such as  myText1, myText2, then to access the variable names dynamically, you can use a loop...
<cfloop index="kk" from=1 to="#form.numberRecords#">

   <cfset theValue = form["myTEXt" & kk]>
    --- the form field value is now in TheValue variable ---

</cfloop>

Open in new window

0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Database structure 4 155
Cold Fusion Session Timing Out 11 82
Fixing Old Legacy Code 1 45
CFSPREADSHEET CF2016 overwrites single sheet 22 36
PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

685 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