cfselect bind to cfc not working?

Discussion in 'Programming' started by loki421, Nov 27, 2008.

  1. #1
    Hi all,

    I have a very irritating problem that i've been trying to solve now for the last couple of weeks, and i'm just not having any joy :(

    I have a front page with 6 cfselect boxes that populate from the previous selection (using a cfc). Now i can get this page to work locally in IE7, Safari, GoogleChrome, but not Firefox (locally). When i upload it to the server it doesn't work either. I have enabled debugging in IE7 and i get this error: A Runtime Error has occured. Exception thrown and not caught. (From the server copy).

    i can send anyone who thinks they can help the link to the live page, but don't want to post it on here, as you can understand.

    So yeah, basically i think it's a display problem, as it won't work in FireFox loacally.

    So here's the code to the front 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>Localhost file</title>
    <style type="text/css">
    <!--
    .style2 {
    	font-weight: bold
    }
    .style4 {
    	font-weight: bold;
    	font-size: small;
    }
    .style6 {
    	font-size: small
    }
    .style8 {
    	color: #FFFFFF
    }
    .style9 {
    	font-weight: bold;
    	font-size: small;
    	color: #FFFFFF;
    }
    .style10 {
    	font-size: small;
    	color: #FFFFFF;
    }
    .style11 {
    	color: #00FF00
    }
    .style12 {
    	color: #FF0000;
    	font-weight: bold;
    }
    #title {
    	padding: 5px;
    	width: 600px;
    	background-color: #666666;
    	border: 2px solid #FF0000;
    }
    #image {
    	width: 200px;
    	float: left;
    }
    .style13 {
    	color: #FFFFFF;
    	font-weight: bold;
    	font-size: medium;
    }
    a:link {
    	color: #333333;
    }
    a:visited {
    	color: #333333;
    }
    a:hover {
    	color: #00FF00;
    }
    body {
    	background-image: url(images/ghg_logo.jpg);
    	background-repeat: no-repeat;
    }
    body, td, th {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    }
    .style16 {
    	color: #FFFFFF;
    	font-size: x-small;
    }
    .style17 {
    	color: #FFFF00
    }
    -->
    </style>
    </head>
    <body bgcolor="#FFFFFF">
    <style type="text/css">
    <!--
    .style1 {color: #FF0000}
    .style2 {color: #333333}
    body,td,th {
    	font-family: Verdana, Arial, Helvetica, sans-serif;
    	font-size: x-small;
    	color: #333333;
    }
    -->
    </style>
    <div align="center">
      <div class="style13" id="title">Please complete all fields...</div>
      <br/>
      <br/>
      <br/>
      <cfoutput>
        <cfform name="quote" >
          <table width="984" border="0">
            <tr>
              <td colspan="2" nowrap="nowrap" bgcolor="##333333"><span class="style10"><strong>Select your vehicle</strong></span>:</td>
              <td width="43">&nbsp;</td>
              <td width="150">&nbsp;</td>
              <td width="83">&nbsp;</td>
              <td width="150">&nbsp;</td>
              <td width="81">&nbsp;</td>
              <td width="170">&nbsp;</td>
            </tr>
            <tr>
              <td width="129">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="24" bgcolor="##333333"><span class="style8">Manufacturer:</span></td>
              <td bgcolor="##333333"><div align="left">
    		  <!--- First Ajax Control - Auto Bound --->
                  <cfselect name="select_Manufacturer" bind="cfc:cf-select.get_Manufacturer()"
          display="manufacturer_ID" value="manufacturer_ID" bindonload="true" required="yes" message="Please Select Manufacturer"/>
                </div></td>
              <td bgcolor="##333333"><span class="style8">Model:</span></td>
              <td bgcolor="##333333"><div align="left">
    		  <!--- Second Ajax Control - Bound on Selection of Select_Manufacturer--->		  
                  <cfselect name="select_Model" bind="cfc:cf-select.get_Model({select_Manufacturer})"
          display="model_ID" value="model_ID" required="yes" message="Please Select Model"/>
                </div></td>
              <td bgcolor="##333333"><span class="style8">Specification:</span></td>
              <td bgcolor="##333333"><div align="left">
    		  <!--- Third Ajax Control - Bound on Selection of Select_Model --->		  		  
                  <cfselect name="select_Spec" bind="cfc:cf-select.get_Spec({select_Model})"
          display="spec_ID" value="spec_ID" required="yes" message="Please Select Specifiction"/>
                </div></td>
              <td bgcolor="##333333"><span class="style8">Transmission:</span></td>
              <td bgcolor="##333333"><div align="left">
    		  <!--- Fourth Ajax Control - Bound on Selection of Select_Spec--->		  		  
               <cfselect name="select_Trans" bind="cfc:cf-select.get_Trans({select_Spec})"
          display="trans_ID" value="trans_ID" required="yes" message="Please Select Trans"/> 
                </div></td>
            </tr>
            <tr>
              <td height="21">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="24">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td colspan="5" rowspan="10">
                  <cfif IsDefined("form.select_manufacturer") >
                    <div align="left">
                      <cfquery datasource="quote-system" name="manu_cost">
    	SELECT cost 
    	AS manu_cost 
    	FROM manufacturer_table  
    	WHERE manufacturer_id = "#form.select_manufacturer#"
            </cfquery>
                      <cfquery datasource="quote-system" name="model_cost">
    	SELECT cost 
        AS model_cost 
        FROM model_table 
        WHERE model_id = "#form.select_model#" 
    	AND sub_manufacturer_ID = "#form.select_manufacturer#"
            </cfquery>
                      <cfquery datasource="quote-system" name="spec_cost">
    	SELECT cost 
        AS spec_cost 
        FROM spec_table 
        WHERE spec_ID = "#form.select_spec#"
    	AND sub_model_ID = "#form.select_model#" 
            </cfquery>
                      <cfquery datasource="quote-system" name="trans_cost">
    SELECT cost
    AS trans_cost
    FROM trans_table
    WHERE trans_ID = "#form.select_trans#"
    AND sub_spec_ID = "#form.select_spec#"
            </cfquery>
                      <cfquery datasource="quote-system" name="deposit_amount">
    SELECT deposit_amount
    AS deposit_amount
    FROM deposit
            </cfquery>
                      <cfquery datasource="quote-system" name="term">
    SELECT months_amount
    AS months_amount
    FROM term
            </cfquery>
                      <cfquery datasource="quote-system" name="mileage_cost">
    SELECT mileage_cost
    AS mileage
    FROM mileage
            </cfquery>
                      <span class="style12">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Your quote:</span></div>
                    <table width="606" border="0" cellpadding="2">
                      <tr>
                        <td width="600" nowrap="nowrap" bgcolor="##333333"><div align="left"><span class="style9">#form.select_manufacturer#</span><span class="style10">#manu_cost.manu_cost# <strong><strong>#form.select_model#</strong> #form.select_spec#</strong></span><span class="style6"><strong>:<span class="style8"> &pound;<strong>#spec_cost.spec_cost#</strong></span> </strong></span></div></td>
                      </tr>
                      <tr>
                        <td nowrap="nowrap"><div align="left"><span class="style2">#form.select_trans# </span>Add: &pound;#trans_cost.trans_cost#</div></td>
                      </tr>
                      <tr>
                        <td><div align="left"><strong>Total vehicle cost:</strong>
                            <cfset vehicle_price = (model_cost.model_cost + spec_cost.spec_cost + trans_cost.trans_cost) - deposit_test/>
                            &pound;#vehicle_price#</div></td>
                      </tr>
                      <tr>
                        <td><div align="left"><span class="style2">Deposit:</span> &pound;#deposit_test#</div></td>
                      </tr>
                      <tr>
                        <td><div align="left"><span class="style2">Term:</span> #select_Term# mothly payments</div></td>
                      </tr>
                      <tr>
                        <td><div align="left"><span class="style2">Residual Value of vehicle after #select_Term# months: </span>&pound;#select_mileage#</div></td>
                      </tr>
                      <tr>
                        <td><div align="left"><strong>#select_Term#</strong> months flat rate of <strong>#flat_rate#</strong>% =
                            <cfset flat_rate = (flat_rate * select_Term) / 12 />
                            <strong>#flat_rate#</strong>%</div></td>
                      </tr>
                      <tr>
                        <td><div align="left">Amount on finance:
                            <cfset finance_amount =  (#vehicle_price# - select_Mileage) />
                            <strong>&pound;#finance_amount#</strong></div></td>
                      </tr>
                      <tr>
                        <td><div align="left">Iterest on amount financed:
                            <cfset interest = ((#finance_amount# / 100) * #flat_rate#) />
                            <strong>&pound;#interest#</strong></div></td>
                      </tr>
                      <tr>
                        <td><div align="left">Monthly total so far:
                            <cfset total1 = (#interest# + #finance_amount#) / select_Term />
                            <strong>&pound;#total1#</strong></div></td>
                      </tr>
                      <tr>
                        <td><div align="left">APR over <strong>#select_Term#</strong> months =
                            <cfset residualAPR = (apr_amount * select_Term) / 12 />
                            <strong>#residualAPR#%</strong></div></td>
                      </tr>
                      <tr>
                        <td><div align="left">Total interest on residual =
                            <cfset residual1 = ((select_Mileage / 100) * residualAPR) />
                            <strong>&pound;#residual1#</strong></div></td>
                      </tr>
                      <tr>
                        <td><div align="left">monthly interest payment =
                            <cfset residual2 = #residual1# / select_Term />
                            <strong>&pound;#residual2#</strong></div></td>
                      </tr>
                      <tr>
                        <td><div align="left"></div></td>
                      </tr>
                      <tr>
                        <td bgcolor="##333333"><div align="left"><span class="style8"> &nbsp;&nbsp;Total Monthly repayment on contract hire:</span>
                            <cfset total = #residual2# + #total1# />
                            <span class="style4 style6 style11">&pound;#total#</span></div></td>
                      </tr>
                      <tr>
                        <td bgcolor="##333333"><div align="left"><span class="style8"> &nbsp;&nbsp;Total Monthly repayment on PCP: </span>
                            <cfset pcp = ((#total#/100) * 17.5) />
                            <cfset pcptotal = (#pcp# + #total#) />
                            <span class="style6 style17"><strong>&pound;#pcptotal# </strong></span><span class="style16">(including 17.5% vat)</span></div></td>
                      </tr>
                    </table>
                  </cfif>
               </td>
            </tr>
    	
            <tr>
              <td height="21" colspan="2" bgcolor="##CCCCCC"><strong>Choose finance:</strong></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td nowrap="nowrap" bgcolor="##CCCCCC"><div align="right">Deposit amount:</div></td>
              <td width="144"><div align="left">
                  <cfinput type="text" name="deposit_test" value="" required="yes" message="Please enter Deposit Amount">
                </div></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td nowrap="nowrap" bgcolor="##CCCCCC"><div align="right">Flat rate amount</div></td>
              <td><div align="left">
                  <cfinput type="text" name="flat_rate" width="20" required="yes" message="Please enter Flat Rate Amount">
                </div></td>
              <td><div align="left">%</div></td>
            </tr>
            <tr>
              <td nowrap="nowrap" bgcolor="##CCCCCC"><div align="right">APR</div></td>
              <td><div align="left">
                  <cfinput type="text" name="apr_amount" width="10" required="yes" message="Please enter APR">
                </div></td>
              <td><div align="left">%</div></td>
            </tr>
            <tr>
              <td nowrap="nowrap" bgcolor="##CCCCCC"><div align="right">Finance over:</div></td>
              <td><div align="left">
                  <cfselect name="select_Term" bind="cfc:cf-select.get_Term()" bindonload="true" display="months_ID" value="months_amount" required="yes" message="Please select Term"/>
                </div></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td nowrap="nowrap" bgcolor="##CCCCCC"><div align="right">Mileage:</div></td>
              <td><div align="left">
                  <cfselect name="select_Mileage" bind="cfc:cf-select.get_Mileage({select_Spec})" bindonload="true" display="mileage_ID" value="mileage_cost" required="yes" message="Please Select Mileage"/>
                </div></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td bgcolor="##CCCCCC">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="26" bgcolor="##CCCCCC">&nbsp;</td>
              <td bgcolor="##CCCCCC"><div align="center">
                  <input type="submit" value="Calcluate Cost" />
                </div></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td height="20" colspan="2" align="left" valign="bottom"><a href="welcomequote.cfm">Return to main page</a></td>
              <td>&nbsp;</td>
            </tr>
          </table>
          <div align="left"></div>
        </cfform>
      </cfoutput></div>
    </body>
    </html>
    
    Code (markup):

    And here's the code for the cfc component:
    
    <cfcomponent>
    <cfset DBSource = "quote-system">
    <cffunction name="get_Manufacturer" access="remote" returnType="query">
    	<cfquery name="get_Man" datasource="#DBSource#">
    		 SELECT * 
             FROM manufacturer_table
    	</cfquery>
    	<cfreturn get_Man>
    </cffunction>
    
    <cffunction name="get_Model" access="remote" returnType="query">
    	<cfargument name="manufacturerid" type="any" required="true">
    	<cfif ARGUMENTS.manufacturerid eq "">
    		<cfset ARGUMENTS.manufacturerid = "0">
    	</cfif>
    	<cfquery name="get_Mod" datasource="#DBSource#">
    		SELECT *
    		FROM model_table 
    		WHERE sub_manufacturer_ID = "#ARGUMENTS.manufacturerid#"
    	</cfquery>
    	<cfreturn get_Mod>
    </cffunction>
    
    <cffunction name="get_Spec" access="remote" returnType="query">
    	<cfargument name="modelid" type="any" required="true">
    	<cfif ARGUMENTS.modelid eq "">	
    		<cfset ARGUMENTS.modelid = "0">
    	</cfif>
    	<cfquery name="get_Sp" datasource="#DBSource#">
    		SELECT *
    		FROM spec_table
    		WHERE sub_model_ID = "#ARGUMENTS.modelid#"
    	</cfquery>
    		<cfreturn get_Sp>
    </cffunction>
    
    <cffunction name="get_Trans" access="remote" returnType="query">
    	<cfargument name="specid" type="any" required="true">
    	<cfif ARGUMENTS.specid eq "">	
    		<cfset ARGUMENTS.specid = "0">
    	</cfif>
    	<cfquery name="get_Tr" datasource="#DBSource#">
    		SELECT *
    		FROM trans_table
    		WHERE sub_spec_ID = "#ARGUMENTS.specid#"
    	</cfquery>
    		<cfreturn get_Tr>
    </cffunction>
    
    <cffunction name="get_Extra" access="remote" returnType="query">
    	<cfargument name="transid" type="any" required="true">
    	<cfif ARGUMENTS.transid eq "">	
    		<cfset ARGUMENTS.transid = "0">
    	</cfif>
    	<cfquery name="get_Ex" datasource="#DBSource#">
    		SELECT *
    		FROM extras_table
    		WHERE sub_trans_ID = "#ARGUMENTS.transid#"
    	</cfquery>
    		<cfreturn get_Ex>
    </cffunction>
    
    <cffunction name="get_Term" access="remote" returnType="query">
    	<cfquery name="get_Term" datasource="#DBSource#">
        SELECT months_ID, months_amount
        FROM term
        </cfquery>
        <cfreturn get_Term>
    </cffunction>
    
    <cffunction name="get_Mileage" access="remote" returnType="query">
    	<cfargument name="mileageid" type="any" required="true">
    	<cfif ARGUMENTS.mileageid eq "">
    		<cfset ARGUMENTS.mileageid = "0">
    	</cfif>
    	<cfquery name="get_Mileage" datasource="#DBSource#">
    		SELECT *
    		FROM mileage 
    		WHERE sub_spec_ID = "#ARGUMENTS.mileageid#"
    	</cfquery>
    	<cfreturn get_Mileage>
    </cffunction>
    
    </cfcomponent>
    
    Code (markup):
    I am very new to ColdFusion, so please be patient with me if i don't fully understand your answers, or ask you to explain a little more.

    I really hope someone out there can help me! I'm totally lost with this now :(

    Many thanks in advance :D
     
    loki421, Nov 27, 2008 IP
  2. robhustle

    robhustle Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I had some issues like this before, where bindings would work locally but not remotely. There are two things off the top of my head I think it could be. One is permissions, the other is the CFC.

    CF Ajax functionality (ie, bindings) causes CF to include a lot of code when your page gets generated. If the server can't find or access this code, you can get errors. In one case, my app didn't have permission to access my "/CFIDE/script" directory, so the necessary files could not be included. In another, I had a config problem with the sandbox security. In both cases, I had errors and my bindings broke.

    What will be important is pinpointing exactly what is causing the error, and getting better debug info to us so we can help. I would suggest posting output from Firebug and / or the coldfusion ajax debugger. You need to know EXACTLY where this breaks and what the state is at the time.

    If it's not the JS code, it could be the output of your CFC. Check your CFC directory and make sure that there is not an applciation.cfm or application.cfc that is producing any output. If there is, it can corrupt the information being returned. To fix this, either move the CFC or neuter the application.cfm / application.cfc so it doesn't produce output. Alternately, add the following line to your CFC:

    <cfcontent type="text/html" reset="yes">

    If you want an explanation on why, here is a link to the thread that helped me diagnose this last problem when I had it:

    http://www.forta.com/blog/index.cfm/2007/5/31/ColdFusion-Ajax-Tutorial-2-Related-Selects

    Good luck.
     
    robhustle, Nov 27, 2008 IP
  3. loki421

    loki421 Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Right, i've had a look around on the server, the 'system' has complete access to the folder. Also, i've viewed the page in FireFox with Firebug enabled, and it's not giving me any out put? I've never used Firebug before, or cfdebug.

    How do i use cfdebug to see what's going on?

    You really sound like you know what you're doing with this, i've got so much to learn! :p

    I've had a look in the folder that the two pages are in, and there's no app.cfm file in there, but there are a couple dotted around in the CF intalled files, should i do anything with them or leave them alone?

    I tried to add that code to my CFC and it really upset everything! lol. Where should i put in in the code? I just placed it in the very top line?

    Had a read through your link too, some good info in there but not quite understanding some of it.

    I have the outputted code from CF, but there's over 1500 lines, and the break happens at line 786. Would you like me to post it so you can have a look? It makes absolutly no sense to me at all :p

    But yeah if you could possibly tell me how to use cfdebug i'll see what i can find out with that.

    But in the meantime, here's the link to the page that's causing me the problems:

    http://www.ghgltd.co.uk/getquote/getquoteinternal.cfm

    Just in case you want to take a look for yourself?

    Thanks for taking the time to help with this, i hope we can get this fixed :D I'd be very very happy! lol
     
    loki421, Nov 27, 2008 IP
  4. robhustle

    robhustle Peon

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I checked the live page, but none of the select boxes are populated for me. The only error I got was a JS error that said "userAgentButton is null".

    Can you post the steps to reprodcution for your error?
     
    robhustle, Nov 28, 2008 IP
  5. loki421

    loki421 Guest

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It's all ok now, i've fixed it! Turns out it was a config error server side, i totally wiped CF8 from the server and re-installed, and that fixed them problem, so don't really have an exact solution to this problem, just know that it works now :)

    But i have loaded it to another domain in the top level folder with no app.cfm anywhere in the domain, so maybe, as i had an app.cfm in the top level folder of the link above, that might have been causing trouble too like you said? Who know's, just glad it's working now :D :D
    But thanks a lot for your time!! :D
     
    loki421, Nov 30, 2008 IP