Loop Indexes in Form Names

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default Loop Indexes in Form Names

    See the following code:

    I have form input tag names generate by a loop. For instance:


    <!--- Page 1 --->
    <cfset i=1>
    <cfoutput>
    <cfloop index="i" from="1" to="4">
    <input type="text" name="form-input-name#i#" value="form-input-name#i#" />
    <br />
    </cfloop>
    </cfoutput>
    </form>

    <!--- This outputs four text input fields, named: form-input-name1,
    form-input-name2, form-input-name3, form-input-name4 --->


    <!--- Page 2
    I just want to output the user entered text. How do I do this?
    --->

    <cfoutput>
    <cfloop index="i" from="1" to="4">
    #form-input-name#i## <br /><!--- HOW DO I DO THIS? --->
    </cfloop>
    <cfoutput>

    JohnManhart Guest

  2. Similar Questions and Discussions

    1. Retrieve Form Names and values
      Is there a way to loop through a list of fields that have been submitted to a page?? I know how to do it in asp, but im new to CF. Also do you...
    2. CFMX 7 Creating Duplicate Form Names
      I have a cfloop that creates multiple cfforms. CFMX 7 is generating the same form name for first two forms. This prevents diffferent validations on...
    3. form button names as variables
      perhaps I am just a little tired, but I am having trouble with my form buttons. Firstly I name them like this name=\"round".$counter."heats\"...
    4. Loop form value
      ImageGroup wrote: :: Hi :: :: I have a recordset with x amount of records. This is displayed in a :: table and each record has a text field which...
    5. Can you return the names of the form elements?
      Robb Meade wrote: One way is to use a bubble sort, which will give acceptable performance on small (>100) data sets. dim ar, i , j, vTemp...
  3. #2

    Default Re: Loop Indexes in Form Names

    Use the Evaluate function to create a dynamic variable or form field name.
    -Paul

    <cfoutput>
    <cfloop index="i" from="1" to="4">
    #Evaluate("form.form-input-name" & i)# <br>
    </cfloop>
    <cfoutput>

    dempster Guest

  4. #3

    Default Re: Loop Indexes in Form Names

    actually you dont need to use evaluate

    #form['form-input-name' &amp; i]#
    Pete Thomas Guest

  5. #4

    Default Re: Loop Indexes in Form Names

    Thanks for the answer!
    JohnManhart Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139