Professional Web Applications Themes

variable named field calculated from variable named fields - Macromedia ColdFusion

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?...

  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. #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

Similar Threads

  1. name of field is in variable: how to use in SQL?
    By Burt in forum ASP Database
    Replies: 7
    Last Post: August 4th, 10:12 PM
  2. Replacing variable data between fields - Revisited.
    By Perlwannabe in forum PERL Beginners
    Replies: 4
    Last Post: September 29th, 09:56 PM
  3. Replacing variable data between fields
    By Perlwannabe in forum PERL Beginners
    Replies: 11
    Last Post: September 11th, 01:51 PM
  4. regexp catching variable number of name=value fields?
    By Bruno Boettcher in forum PERL Miscellaneous
    Replies: 0
    Last Post: August 28th, 04:38 PM
  5. Variable in the field name.
    By my in forum ASP
    Replies: 2
    Last Post: July 21st, 10:08 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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