Solved

cfajaxproxy and default items

Posted on 2009-07-15
2
208 Views
Last Modified: 2013-12-24
Hello experts.
After using the following tutorials-solutions:
http://www.experts-exchange.com/Software/Server_Software/Web_Servers/ColdFusion/Q_24563361.html
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_24299747.html
i have a problem binding to the childfield when the value is not numberic.
If i select cobra f.e in the child field i have the rerror vobra is not defined.
I send you the cfm cfc and part of the db table so you can help me to find where   the problem is
Any help?
cfm:
<!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=iso-8859-7" />
<title>Untitled Document</title>
<cfparam name="FORM.S_Hersteller_ID" default="">
<cfparam name="Form.S_Modell_ID" default="">
<script type="text/javascript">
var imdone = false;
var imdone2 = false;
function SelectDefault(x,val) {
 if(!imdone) {
  var dd = document.getElementById('S_Hersteller_ID');
  for(var i = 0; i < dd.length; i++){
   if(dd.options[i].value == val){
    dd.selectedIndex = i;
   }
  }
  imdone = true;
 }
}
 
function SelectsecondDefault(x,val) {
 if(!imdone2) {
  var dd2 = document.getElementById('S_Modell_ID');
  for(var i = 0; i < dd2.length; i++){
 
   if(dd2.options[i].value.match(val) ){
    dd2.selectedIndex = i;
   }
  }
  imdone2 = true;
 }
}
</script>
</head>
 
<body>
<!--- Proxy function --->
<cfajaxproxy bind="javascript:SelectDefault({S_Hersteller_ID},#Form.S_Hersteller_ID#)">
<cfajaxproxy bind="javascript:SelectsecondDefault({S_Modell_ID},#Form.S_Modell_ID#)">
<cfform  action="#cgi.SCRIPT_NAME#?cfdebug" method="post" name="Localiza" preservedata="yes">
<table>
<tr>
<td width="100">Division:</td>
<td width="150">
<cfselect name="S_Hersteller_ID" 
          id="S_Hersteller_ID"
          bind="cfc:testselect6.GetHersteller()"
		  display="Hersteller_Text" 
          value="Hersteller_ID" 
          BindOnLoad="true"
          />
        </td>
   </tr>
<tr>
<td width="100">State:</td>
<td width="150">
<cfselect name="S_Modell_ID" 
          id="S_Modell_ID"
          bind="cfc:testselect6.GetMenu({S_Hersteller_ID})"
		  display="Modell_DE" 
          value="Modell_ID"/>
          </td>
       </tr>
 
</table>
<input name="" type="submit" />
</cfform>
</body>
</html>
cfc:
<cfcomponent output="false">
 <cffunction name="GetHersteller" access="remote" returnType="array">
  <cfargument name="vlangid" required="no" type="string" default="de">
      <cfset var data="">
      <cfset var result=ArrayNew(2)>
      <cfset var i=0>
     <cfquery name="data" datasource="#request.dsn#">
     SELECT Hersteller_ID, Hersteller_Text
     FROM Hersteller
     WHERE 
     Mobiles_Subs_ID = <cfqueryparam cfsqltype="cf_sql_numeric" value="1">
     OR (Hersteller_ID = <cfqueryparam cfsqltype="cf_sql_integer" value="19999">
     AND LANGID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.vlangid#"> )
     OR	(Hersteller_NR = <cfqueryparam cfsqltype="cf_sql_integer" value="-1">
     AND LANGID = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.vlangid#"> )
     ORDER BY Hersteller_NR
     </cfquery>
      <cfloop index="i" from="1" to="#data.RecordCount#">
         <cfset result[i][1]=data.Hersteller_ID[i]>
         <cfset result[i][2]=data.Hersteller_Text[i]>
      </cfloop>
  <cfreturn result>
 </cffunction>
 
 <cffunction name="GetMenu" access="remote" returnType="array">
   <cfargument name="Hersteller_ID" type="any" required="true">
      <cfset var data="">
      <cfset var result=ArrayNew(2)>
      <cfset var i=0>
      
     <cfif arguments.Hersteller_ID NEQ "">
       <cfquery name="data" datasource="#request.dsn#">
        SELECT Auto_ID,Modell_DE, Modell_ID
        FROM Modell_Auto_S
        WHERE Auto_ID = <cfqueryparam cfsqltype="cf_sql_numeric" value="#ARGUMENTS.Hersteller_id#">
        ORDER BY Modell_NR
        </cfquery>
        
         <cfloop index="i" from="1" to="#data.RecordCount#">
         <cfset result[i][1]=data.Modell_ID[i]>
         <cfset result[i][2]=data.Modell_DE[i]>
        </cfloop>
       <cfelse>
        <cfquery name="data" datasource="#request.dsn#">
        SELECT Auto_ID,Modell_DE, Modell_ID
        FROM Modell_Auto_S
        WHERE Modell_NR = <cfqueryparam cfsqltype="cf_sql_numeric" value="20000">
        ORDER BY Modell_NR
        </cfquery>
         <cfset result[1][1]=data.Modell_ID>
         <cfset result[1][2]=data.Modell_DE>
        
     </cfif>
     <cfreturn result>
    </cffunction>
</cfcomponent>
 
db:
Auto_NR	  Auto_ID	     Modell_DE	      Modell_ID
10	          40	             all	
20	          40	             Cobra	             Cobra
30	          40	             other	             9999
40	          70	             all	
50	          70	             MDX	             MDX
60	          70               NSX	             NSX
70	          70	             RSX	             RSX
80	          70	             TL	             TL
90	          70               TSX	             TSX
100	          70	             other	             9999
20000		             Select parent

Open in new window

0
Comment
Question by:Panos
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 24866997
it's a bit hard to help you when you do not say which line of your code throws the error, or what exactly your refer to as 'child field'... but i will take a wild guess that it's the seconf <cfajaxproxy> tag that errors: it looks like your form.S_Modell_ID is not always numeric, thus you need to enclose it in ' (single quotes) in the <cfajaxproxy> tag code, otherwise js will think you are refering to some js variabled called Cobra

<cfajaxproxy bind="javascript:SelectsecondDefault({S_Modell_ID}, '#Form.S_Modell_ID#')">


Azadi
0
 
LVL 2

Author Closing Comment

by:Panos
ID: 31603794
Hi azadi.
Thank you again for your help.
After all the problems i had with the related selects in older questions you have helped me to find a solution, the cfajxproxy did finally do what i want.
regards
Panos
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question