We help IT Professionals succeed at work.
Get Started

Coldfusion cfselect-bind problem

429 Views
Last Modified: 2013-12-24
Hello experts.
I have two related selects and i somehow i don't get the right options in the child field.
I need help to check my code please.
Any help?

<cfset vlangid = 1>
<cfparam name="Form.Berufe_1" default="">
<cfparam name="form.getsubfirst_1" default="">
<cfparam name="form.getsubsecond_1" default="">
<cfform id="SearchForm" name="SearchForm">
<table  align="center">
            <tr>
              <td>
       <fieldset>
        <label for="Berufe_1">Main</label>
           <cfselect name="Berufe_1"
            id="Berufe_1"
            bind="cfc:test.testrelated5.com.test.q_Beruf(#vlangid#)"
            bindonload="true"
            value="Berufe_Id"
            display="Berufe_Text"
            />
         </fieldset>
              </td></tr>
              <tr><td>
       <fieldset>
        <label for="getsubfirst_1">1. Child</label>
            <cfselect name="getsubfirst_1"
            id="getsubfirst_1"
            bind="cfc:test.testrelated5.com.test.getBerufefirstsub({Berufe_1},#vlangid#)"
            bindonload="false"
            value="Subfirstprofi_id"
            display="Subfirstprofi_text"
            />
       </fieldset>
            </tr>
            </table>
 </cfform>
the cfc:
<cfcomponent>
	<cffunction name="q_Beruf" access="remote" returnType="query" output="no">
		<cfargument name="vlangid" required="no" default="3">
		<cfset var data="">
		<cfquery name="data" datasource="#request.dsn#">
         SELECT -1 AS Berufe_ID,'select' AS Berufe_Text
         FROM dbo.Berufe
         UNION
		 SELECT Berufe_ID,Berufe_Text
		 FROM dbo.Berufe
         WHERE Langid = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.vlangid#">
        </cfquery>
		<cfreturn data />
	</cffunction>
    <cffunction name="getBerufefirstsub" access="remote" returnType="query" output="no">
		<cfargument name="vlangid" required="no" default="3">
        <cfargument name="Berufe_1" type="any" required="true" default="">
		<cfset var data="">
        <cfset mylist = '4,5,6'>
		<cfif listfind(mylist,arguments.Berufe_1)>
		 <cfquery name="data" datasource="#request.dsn#">
         SELECT -1 AS Subfirstprofi_id,'select' AS Subfirstprofi_text
         FROM BerufeSubfirst)
         UNION
		 (SELECT Subfirstprofi_id,Subfirstprofi_text
		 FROM BerufeSubfirst
         WHERE MainProfi_ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.Berufe_1#">
         AND (Subfirstprofi_id = 1   or Subfirstprofi_id = 1010)
         AND LangID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.vLangId#">
          ORDER BY Subfirstprofi_text,Subfirstprofi_id ASC
         </cfquery>
       <cfelse>
         <cfquery name="data" datasource="#request.dsn#">
         SELECT Subfirstprofi_id,Subfirstprofi_text
         FROM BerufeSubfirst
         WHERE MainProfi_ID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.berufe_1#">
            <cfif arguments.Berufe_1 NEQ 8 AND arguments.Berufe_1 NEQ 3>
             AND LangID = <cfqueryparam cfsqltype="cf_sql_integer" value="#arguments.vLangId#">
            </cfif>  
        </cfquery> 
       </cfif> 
       <cfreturn data />
	</cffunction>
</cfcomponent>

Open in new window

Comment
Watch Question
Principal Systems Engineer
CERTIFIED EXPERT
Top Expert 2005
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE