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

Re: Problem with CFSELECT(s)

Subject: Re: Problem with CFSELECTs
From: Azadi
Date: Wed, 29 Aug 2007 09:41:28 +0700
Newsgroups: macromedia.coldfusion.cfml_general_discussion

oops! my ad! somehow i have totally missed 2 important things!
1) you do have a control named ServiceID on your page (the first select box)
2) this select box allows multiple selections!!!

the latter means that, if several services were selected, the value of the ServiceID select box is not a number (which is what cf was compaining about in the first place), but a comma-delimited list of numbers!!!
so, to make things right, return your code to its original state (as in
your original post) and change your getService function to the following:
[basically, you need to allow ServiceID argument to be of ANY type, and
change your "data" query's WHERE clause to look up values in a list]
<cffunction name="getService" access="remote" returnType="array">
       <cfargument name="ServiceID" [b]type="any"[/b] 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
[b]WHERE ServiceID IN (<cfqueryparam cfsqltype="cf_sql_varchar" value="#ARGUMENTS.ServiceID#" list="yes">)[/b]
       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>

sorry for the confusion caused previously...

--

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com

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