Solved

Coldfusion retrieve dynamic values

Posted on 2016-10-04
1
27 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

757 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

22 Experts available now in Live!

Get 1:1 Help Now