macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: Problem with CFSELECT(s)

Subject: Re: Problem with CFSELECTs
From: GArlington
Date: Tue, 28 Aug 2007 06:42:40 -0700
Newsgroups: macromedia.coldfusion.cfml_general_discussion
On 28 Aug, 00:43, "K0rrupt" <[email protected]> wrote:
> I'm using cfselect to make an advanced search engine, but i get this error
> about the cfc...
>
>  error:http: Error invoking CFC /testingsite/Service.cfc : The SERVICEID
> argument passed to the getService function is not of type numeric.
>
>  The funny thing is that the cfselects work when i click "OK" on then error
> message and all of them work fine. Just don't want that error to go to the end
> user. Any ideas how i can make this work?
>
>  ========= CFC FILE ===============
>  <cfcomponent output="false">
>
>     <cfset THIS.dsn="aiya_ca">
>
>     <!--- Get array of media types --->
>     <cffunction name="getBusiness" access="remote" returnType="array">
>        <!--- Define variables --->
>        <cfset var data="">
>        <cfset var result=ArrayNew(2)>
>        <cfset var i=0>
>
>        <!--- Get data --->
>        <cfquery name="data" datasource="#THIS.dsn#">
>        SELECT ServiceID, Name
>        FROM Service
>        ORDER BY Name
>        </cfquery>
>
>        <!--- Convert results to array --->
>        <cfloop index="i" from="1" to="#data.RecordCount#">
>           <cfset result[i][1]=data.ServiceID[i]>
>           <cfset result[i][2]=data.Name[i]>
>        </cfloop>
>
>        <!--- And return it --->
>        <cfreturn result>
>     </cffunction>
>
>     <!--- Get art by media type --->
>     <cffunction name="getService" access="remote" returnType="array">
>        <cfargument name="ServiceID" type="numeric" required="true">
>
>        <!--- Define variables --->
>        <cfset var data="">
>        <cfset var result=ArrayNew(2)>
>        <cfset var i=0>
>
>        <!--- Get data --->
>        <cfquery name="data" datasource="#THIS.dsn#">
>        SELECT ServiceTypeID, Name
>        FROM ServiceType
>        WHERE ServiceID = #ARGUMENTS.ServiceID#
>        ORDER BY ServiceTypeID
>        </cfquery>
>
>        <!--- Convert results to array --->
>        <cfloop index="i" from="1" to="#data.RecordCount#">
>           <cfset result[i][1]=data.ServiceTypeID[i]>
>           <cfset result[i][2]=data.Name[i]>
>        </cfloop>
>
>        <!--- And return it --->
>        <cfreturn result>
>     </cffunction>
>
>     <cffunction name="Province" access="remote" returntype="query">
>
>          <cfquery name="qProvince" datasource="#THIS.dsn#">
>          SELECT Name
>          FROM Province
>          ORDER BY Name
>          ASC
>          </cfquery>
>
>         <cfreturn qProvince>
>
>     </cffunction>
>
>  </cfcomponent>
>
>  ========== CFC FILE ==============
>
>  ========== CFM FILE ==============
>
>  <cfinvoke
>   component="AdsInYourArea.canada.cfc.Service"
>   method="Province"
>   returnvariable="qProvince">
>  </cfinvoke>
>
>  <html>
>  <head>
>  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
>  <title>Untitled Document</title>
>  <style type="text/css">
>  <!--
>  .textfield {
>         font-family: Verdana, Arial, Helvetica, sans-serif;
>         font-size: 13px;
>         color: #000000;
>         background-color: #ffffff;
>         border: 1px solid #000000;
>  }
>
>  -->
>  </style></head>
>
>  <body>
>
>  <cfform>
>
>  <table border="0" cellpadding="0" cellspacing="5">
>     <tr>
>        <td>Select Servicice:</td>
>        <td>Select Type </td>
>        <td>Province:</td>
>     </tr>
>     <tr>
>        <td valign="top"><cfselect name="ServiceID"
>              bind="cfc:Service.getBusiness()"
>              bindonload="true"
>                         multiple="yes"
>                         size="5"
>                         class="textfield" /></td>
>
>           <td valign="top"><cfselect name="ServiceTypeID"
>              bind="cfc:Service.getService({ServiceID})"
>                         multiple="yes"
>                         size="5"
>                         class="textfield" /></td>
>
>           <td valign="top">
>             <cfselect name="Province"
>                                   multiple="yes"
>                                   size="5"
>                                   required="yes"
>                                   message="Please choose a Province."
>                                   class="textfield">
>           <cfoutput query="qProvince">
>              <option value="#Name#">#Name#</option>
>            </cfoutput>            </cfselect>        </td>
>     </tr>
>  </table>
>
>  </cfform>
>
>  </body>
>  </html>
>
>  ==============CFM FILE ============

You are not going to get the expected behaviour anyway with your
<cfselect ... multiple="yes" ... />
because your bindings will clear and re-populate your selects when you
pick any of the options in your previous select box.


<Prev in Thread] Current Thread [Next in Thread>