We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

CFINPUT Binding Multiple Values

Medium Priority
946 Views
Last Modified: 2012-05-06
Hi Guys,

I have a flash form and I want it to add the values of multiple columns together to create a total. SQL will not do it, so I need to figure out how to make cf do it. As the data needs to include a number the user will type in, it needs to bind the data. Now I know how to bind 1cfinput field to another, but I need to bind 11 cfinputs (All Numbers) to generate a total number.

The code I am trying is:

<cfinput type="hidden" name="total" bind="{Number(ordramt.text)+Number(anntotal.text)+Number(cartotal.text)+Number(chltotal.text)+Number(keptotal.text)+Number(martotal.text)+Number(mortotal.text)+Number(spttotal.text)+Number(stwtotal.text)+Number(suntotal.text)+Number(toototal.text)}">

The problem is whenever the program tries to run this line, it does not generate the form.
<cfquery name="checkfororder" datasource="#Application.DSN#" dbtype="odbc">
SELECT *
FROM fruitorders
WHERE ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfif #checkfororder.recordcount# EQ 0>
<cfelse>
<cfquery name="updann" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET ann = '0'
WHERE ann = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updcar" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET car = '0'
WHERE car = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updchl" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET chl = '0'
WHERE chl = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updkep" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET kep = '0'
WHERE kep = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updmar" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET mar = '0'
WHERE mar = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updmor" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET mor = '0'
WHERE mor = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updspt" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET spt = '0'
WHERE spt = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updstw" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET stw = '0'
WHERE stw = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updsun" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET sun = '0'
WHERE sun = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
 
<cfquery name="updtoo" datasource="#Application.DSN#" dbtype="odbc">
UPDATE fruitorders
SET too = '0'
WHERE too = ''
AND ipn = '#form.ipn#'
AND orderdate = '#form.orderdate#'
</cfquery>
</cfif>
 
<cfquery name="orderhistmon" datasource="#Application.DSN#" dbtype="odbc">
SELECT ordramt, stockcount
FROM orders
WHERE dtordered >= (GETDATE()-7)
AND ipn = '#form.ipn#'
AND store = '#session.store#'
AND orderday = 'Monday'
</cfquery>
 
 
<cfquery name="orderhisttue" datasource="#Application.DSN#" dbtype="odbc">
SELECT ordramt, stockcount
FROM orders
WHERE dtordered >= (GETDATE()-7)
AND ipn = '#form.ipn#'
AND store = '#session.store#'
AND orderday = 'Tuesday'
</cfquery>
 
<cfquery name="orderhistwed" datasource="#Application.DSN#" dbtype="odbc">
SELECT ordramt, stockcount
FROM orders
WHERE dtordered >= (GETDATE()-7)
AND ipn = '#form.ipn#'
AND store = '#session.store#'
AND orderday = 'Wednesday'
</cfquery>
 
<cfquery name="orderhistthu" datasource="#Application.DSN#" dbtype="odbc">
SELECT ordramt, stockcount
FROM orders
WHERE dtordered >= (GETDATE()-7)
AND ipn = '#form.ipn#'
AND store = '#session.store#'
AND orderday = 'Thursday'
</cfquery>
 
<cfquery name="orderhistfri" datasource="#Application.DSN#" dbtype="odbc">
SELECT ordramt, stockcount
FROM orders
WHERE dtordered >= (GETDATE()-7)
AND ipn = '#form.ipn#'
AND store = '#session.store#'
AND orderday = 'Friday'
</cfquery>
 
<cfquery name="orderhistsat" datasource="#Application.DSN#" dbtype="odbc">
SELECT ordramt, stockcount
FROM orders
WHERE dtordered >= (GETDATE()-7)
AND ipn = '#form.ipn#'
AND store = '#session.store#'
AND orderday = 'Saturday'
</cfquery>
 
<cfquery name="orderhistsun" datasource="#Application.DSN#" dbtype="odbc">
SELECT ordramt, stockcount
FROM orders
WHERE dtordered >= (GETDATE()-7)
AND ipn = '#form.ipn#'
AND store = '#session.store#'
AND orderday = 'Sunday'
</cfquery>
 
<cfquery name="ordertoday" datasource="#Application.DSN#" dbtype="odbc">
SELECT ordramt, stockcount
FROM orders
WHERE dtordered = (GETDATE())
AND ipn = '#form.ipn#'
AND store = '#session.store#'
</cfquery>
 
<cfquery name="ipninfo" datasource="#Application.DSN#" dbtype="odbc">
SELECT *
FROM fruitipn
WHERE ipn = '#form.ipn#'
AND store = '#session.store#'
</cfquery>
 
<cfquery datasource="#Application.DSN#" dbtype="odbc" name="checkexist">
SELECT *
FROM orders
WHERE orderid = '#form.orderid#'
AND ipn = '#form.ipn#'
</cfquery>
 
<cfquery datasource="#Application.DSN#" dbtype="odbc" name="checkcount">
SELECT *
FROM orders
</cfquery>
 
<cfif #checkexist.recordcount# EQ 0>
<cfset current = "#checkcount.recordcount#"+1>
<cfelse>
</cfif>
 
<cfquery datasource="#Application.DSN#" dbtype="odbc" name="checkbuyer">
SELECT *
FROM fruitorders
</cfquery>
 
<cfoutput query="checkbuyer">
<cfif #checkbuyer.recordcount# NEQ 0>
<cfset orderentryid = "#checkbuyer.recordcount#"+1>
<cfelse>
</cfif>
</cfoutput>
 
<cfquery datasource="#Application.DSN#" dbtype="odbc" name="checksoh">
SELECT *
FROM rocsoh
WHERE ipn = '#form.ipn#'
</cfquery>
 
<cfquery datasource="#Application.DSN#" dbtype="odbc" name="totals">
SELECT ann,car,chl,kep,mar,mor,spt,stw,sun,too
FROM fruitorders
WHERE orderdate = '#form.orderdate#'
</cfquery>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Store Orders</title>
</head>
 
<body bgcolor="#EEEEEE">
<table align="center" width="75%" bgcolor="#EEEEEE">
 
	<tr>
	
		<td>
 
<table>
 
	<tr>
    
    	<td>
		<cfoutput>
        <h1>FRUIT ORDER - For #form.orderday# #DateFormat(form.orderdate, 'dd/mm/yyyy')#</h1>
        </cfoutput>
        <br />
        
        <font size="+1"><b>Order History:</b></font> - <i>Last 7 Days</i> 
        
<table>
 
	<tr>
    
    	<td>
        <b>Mon:</b>
        </td>
        
        <td>
        <b>Tue:</b>
        </td>
        
        <td>
        <b>Wed:</b>
        </td>
        
        <td>
        <b>Thur:</b>
        </td>
        
        <td>
        <b>Fri:</b>
        </td>
        
        <td>
        <b>Sat:</b>
        </td>
        
        <td>
        <b>Sun:</b>
        </td>
    
    </tr>
    
    <tr>
    
    	<td>
        <cfoutput query="orderhistmon">
        #ordramt#
        </cfoutput>
        </td>
        
    	<td>
        <cfoutput query="orderhisttue">
        #ordramt#
        </cfoutput>
        </td>
        
        <td>
        <cfoutput query="orderhistwed">
        #ordramt#
        </cfoutput>
        </td>
        
        <td>
        <cfoutput query="orderhistthu">
        #ordramt#
        </cfoutput>
        </td>
        
        <td>
        <cfoutput query="orderhistfri">
        #ordramt#
        </cfoutput>
        </td>
        
        <td>
        <cfoutput query="orderhistsat">
        #ordramt#
        </cfoutput>
        </td>
        
        <td>
        <cfoutput query="orderhistsun">
        #ordramt#
        </cfoutput>
        </td>
    
    </tr>
 
</table>
        
       <cfform format="flash" skin="haloblue" action="orderitemfrtproc.cfm" width="500" height="325">
 
		<cfformgroup type="panel" style="background-color:##E3ECF3" query="ipninfo" label="Fruit Order">
 
		<cfformitem type="html">
				<b>ITEM: </b>
				<cfoutput query="ipninfo" maxrows="1">
 				#ipn# #itemgroup# #subgroup# #description# #variety# #measure#
				</cfoutput>        	   
           
            <br />
            <br />
            
    	        
                <cfoutput query="ipninfo">
                <b>Carton Size:</b> #cartonsize#
      			</cfoutput>
        
            <br />
          
            
                    
    	  		
                <cfoutput query="ipninfo">
                <b>Last ROC Sell:</b> $#lastrocsell#
      			</cfoutput>
                
                <br />
                
                <cfoutput query="ipninfo">
                <b>Last Cost:</b> $#lastcost#
      			</cfoutput>
                
            </cfformitem>
                
                <cfformitem type="html">
                <cfoutput query="ipninfo">
                <cfinput type="text" size="10" name="stockcount" label="Stock Count:" required="yes" value="#stockcount#" message="Stock Count Required - Must Be A Number" validate="integer" tooltip="Count By KG / EA">
            </cfoutput>
     		</cfformitem>
            
            <br />
            <br />
            	
            <cfformitem type="html">
            <cfoutput query="ipninfo">
                <cfinput type="text" size="10" name="ordramt" label="Order Amount:" required="yes" value="#ordramt#" message="Order Amount Required - Must Be A Number" validate="integer" tooltip="Order By Carton">
 			</cfoutput>
            </cfformitem>
            
            <br />
            <br />
            
            <cfinput type="hidden" name="orderid" value="#form.orderid#">
	        <cfinput type="hidden" name="orderdate" value="#form.orderdate#">
            <cfinput type="hidden" name="orderday" value="#form.orderday#">
    	    <cfinput type="hidden" name="ipn" value="#form.ipn#">
        	<cfinput type="hidden" name="store" value="#session.store#">
            <cfinput type="hidden" name="orderentryid" value="#orderentryid#">
        <cfoutput query="ipninfo">
	        <cfinput type="hidden" name="itemgroup" value="#itemgroup#">
    	    <cfinput type="hidden" name="subgroup" value="#subgroup#">
	        <cfinput type="hidden" name="description" value="#description#">
        	<cfinput type="hidden" name="variety" value="#variety#">
	        <cfinput type="hidden" name="measure" value="#measure#">
    	    <cfinput type="hidden" name="cartonsize" value="#cartonsize#">            
        </cfoutput>
       
        <cfif #checkexist.recordcount# EQ 0>
         <cfoutput>
        <cfinput type="hidden" name="entryid" value="#current#">
        </cfoutput>
        <cfelse>
         <cfoutput query="checkexist">
        <cfinput type="hidden" name="entryid" value="#entryid#">
        </cfoutput>
        </cfif>
        
  	      <cfinput type="hidden" name="dtordered" value="#DateFormat(Now())#">
    	    <cfinput type="hidden" name="dtlastordered" value="#DateFormat(Now())#">
        	<cfinput type="hidden" name="idset" value="yes">
            <cfformitem type="html">
            <cfif #checksoh.recordcount# EQ 0>
            <cfinput type="hidden" name="soh" value="0">
            <cfelse>
            <cfoutput query="checksoh">
            <cfinput type="hidden" name="soh" value="#soh#">
            </cfoutput>
            </cfif>
            <cfif #checkfororder.recordcount# EQ 0>
            <cfinput type="hidden" name="total" bind="{Number(ordramt.text)}">
            <cfelse>
            <cfoutput query="checkfororder">
            <cfinput type="hidden" name="anntotal" value="#ann#">
            <cfinput type="hidden" name="cartotal" value="#car#">
            <cfinput type="hidden" name="chltotal" value="#chl#">
            <cfinput type="hidden" name="keptotal" value="#kep#">
            <cfinput type="hidden" name="martotal" value="#mar#">
            <cfinput type="hidden" name="mortotal" value="#mor#">
            <cfinput type="hidden" name="spttotal" value="#spt#">
            <cfinput type="hidden" name="stwtotal" value="#stw#">
            <cfinput type="hidden" name="suntotal" value="#sun#">
            <cfinput type="hidden" name="toototal" value="#too#">
            </cfoutput>
            <cfinput type="hidden" name="total" bind="{Number(ordramt.text)+Number(anntotal.text)+Number(cartotal.text)+Number(chltotal.text)+Number(keptotal.text)+Number(martotal.text)+Number(mortotal.text)+Number(spttotal.text)+Number(stwtotal.text)+Number(suntotal.text)+Number(toototal.text)}">
            
            </cfif>
            <cfoutput query="ipninfo">
            <cfinput type="text" size="30" maxlength="50" label="Comments" name="comments" value="#comments#">
            </cfoutput>
            </cfformitem>
                       
            <cfinput type="submit" name="submititem" value="Add To Order">
           
 			</cfformgroup>
            
        </cfform>
        </td>
    
    </tr>
   
</table>
		</td>
	
	</tr>
	
</table>
</body>
</html>

Open in new window

Comment
Watch Question

Here is a sample page and cfc. This will add the numbers together. Just add the rest of you fields.
The arguments in the cfc need to be in the same order as in your bind statement.

************ cfm page *******************
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
 
<body>
 
<cfform method="get" name="test" preloader="no">
<cfinput type="text" name="ordramt">
<cfinput type="text" name="anntotal">
<cfinput type="text" name="result" bind="cfc:test.sendinvnow({TEST@click},{ordramt@},{anntotal@})">
<cfinput type="button" name="TEST" value="TEST">
</cfform>
</body>
</html>
 
****************** test.cfc page ***************
 
<cfcomponent>
	<cffunction name="sendinvnow" access="remote" returntype="string">
 
		<cfargument name="TEST" required="yes">
        <cfargument name="ordramt" required="yes">
        <cfargument name="anntotal" required="yes">
        
        
        <cfset returnthenumber = anntotal + ordramt>
		
		<cfreturn returnthenumber />
	</cffunction>
</cfcomponent>

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.