Pulling supplies, cost from database and multiplying by quantity, returning total in ColdFusion -


i overwhelmed, not thinking right trying write simple code. have select option, when supply selected should pull cost database , populate appropriate field. user enters quantity , calculates total without refreshing page. "submit()" value on cfselect clears field, populates cost. don't know how else save values without submitting form. goal have 25+ rows can select supplies & quantity , populate totals each , grand total.

<cfquery name="supplies" datasource="application_dev">     select * supplies </cfquery>   <cfoutput> <cfform>     <table>         <tr>         <td colspan=3>additional supplies</td>         </tr>         <tr>         <td>date</td>         <td>supply</td>         <td>cost</td>         <td>quantity</td>         <td>total</td>         </tr>         <tr>         <td><cfinput type="datefield" name="date_01"></td>         <td><cfselect name="supply_01" onchange="submit()">                 <option value="0"></option>             <cfloop query="supplies">                 <option value="#supplies.id#">#supplies.supply#</option>             </cfloop>             </cfselect>         </td>         <cfif isdefined("form.supply_01")>             <cfquery name="supply_cost" datasource="application_dev">                 select unitcost supplies                 id = #form.supply_01#             </cfquery>             <td><cfinput type="integer" name="unitcost_01" readonly="yes" value="#supply_cost.unitcost#"></td>         <cfelse>             <td><cfinput type="text" readonly="yes" name="null"></td>         </cfif>         <td><cfinput type="integer" name="quantity_01" validateat="onblur"></td>         <cfif (isdefined("form.quantity_01") , isdefined("form.unitcost_01"))>             <cfset totalsum_01 = (lsparsenumber(#form.quantity_01#) * lsparsenumber(#form.unitcost_01#))>             <td><cfinput type="integer" readonly="yes" name="total_01" value="#totalsum_01#"></td>         <cfelse>             <td><cfinput type="integer" readonly="yes" name="null"></td>         </cfif>         </tr>     </table> </cfform>   </cfoutput>           


Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -