Solved

Coldfusion retrieve dynamic values

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

19 Experts available now in Live!

Get 1:1 Help Now