variable named field calculated from variable named fields

Ask a Question related to Macromedia ColdFusion, Design and Development.

  1. #1

    Default variable named field calculated from variable named fields


    I have two form fields per line defined in a cfloop thusly:


    <cfloop index="i" from= "1" to= "100" Step="1">
    <cfif isdefined("form.item_number_" & "#i#")>
    <tr>
    <td>
    <input type=text name="item_Quantity_" & "#i#"
    value="#FORM["item_Quantity_" & i]#">

    <input type=text readonly name="amount_" & "#i#"
    value="#FORM["amount_" & i]#">

    </td>
    </tr>
    </cfif>
    </cfloop>

    I want to add a third field name "extended_amount_" & "#i#"

    whose value will be the product of the variably named item_quantity
    and item amount fields.

    What is the grammatical construction to calculate the extended amount
    for each line?
    Chris Kemp Guest

  2. Similar Questions and Discussions

    1. name of field is in variable: how to use in SQL?
      Hi, The name of the field is in variable 'a'. How can i use it into SQL? This doesn't work: <% a="name" set obj =...
    2. Replacing variable data between fields - Revisited.
      I posted a problem to the mailing list with a similar question I had some time ago regarding replacing data between fields. Unfortunately, I am...
    3. Replacing variable data between fields
      I have a text file that has various addresses in different formats. I need to remove any items that are not part of the address so the output is...
    4. regexp catching variable number of name=value fields?
      Hello, i have a configuration file where i am slowly migrating to XML like notation (tryed XML::Parser, but that one doesn't suit well into the...
    5. Variable in the field name.
      Hi All, I have one question. Usually, we can get data from table by using rst("userid") because we know the column name userid. Now, I have a...
  3. #2

    Default Re: variable named field calculated from variable namedfields

    One way ..


    <cfset extendedAmount = VAL(FORM["item_Quantity_" & i]) * VAL(FORM["amount_" & i])>
    <input type="text" readonly name="extended_amount_#i#" value="#extendedAmount#">
    mxstu 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