Copy link to clipboard
Copied
<cfargument name="StateID" type="any" default="">
<cfargument name="LocationID2" type="any" default="">
<cfset var data ="">
<cfquery datasource="#ds#" name="data">
SELECT s.State_ID, s.State, l.Location_ID, l.Area, l.State_ID, r.Name, r.Location_ID
FROM State s, Location l, Restaurants r
WHERE 0=0
AND r.Location_ID = l.Location_ID
AND l.State_ID = s.State_ID
<cfif #ARGUMENTS.LocationID2# LT 9>
AND l.State_ID = (#ARGUMENTS.LocationID2#)
<cfelse>
AND l.Location_ID = (#ARGUMENTS.LocationID2#)
</cfif>
This is the code in component file, it is working with normal form with action.
But when i try to make it with ajax, something like <cfdiv bind="......." > , it get error with
58 : AND l.St
ate_ID = (#ARGUMENTS.LocationID2#)
59 : <cfelse>
60 : AND l.Location_ID = (#ARGUMENTS.LocationID2#)
61 : </cfif>
but when i take away the cfelse , it working without any error. I just feel weird , can some one please give me some tips ?
It's hard without the error message but just for kicks, try changing your if statement to the following:
<cfif val(ARGUMENTS.LocationID2) LT 9>
AND l.State_ID = #val(ARGUMENTS.LocationID2)#
<cfelse>
AND l.Location_ID = #val(ARGUMENTS.LocationID2)#
</cfif>
If this works then the function caller is not providing the LocationID2 argument and since your declaration does not require a value and defaults it to "", arguments.LocationID2 is not a number.
Copy link to clipboard
Copied
You say you get an error, but you don't say what the actual error message is. All you've given us is the context of where the error is occurring.
So it's difficult to say anything sensible about this.
--
Adam
Copy link to clipboard
Copied
Did you pass two numeric arguments?
Copy link to clipboard
Copied
Ya, i pass two numeric arguments after i continue click with it.
Just the error will pop up.
Copy link to clipboard
Copied
It's hard without the error message but just for kicks, try changing your if statement to the following:
<cfif val(ARGUMENTS.LocationID2) LT 9>
AND l.State_ID = #val(ARGUMENTS.LocationID2)#
<cfelse>
AND l.Location_ID = #val(ARGUMENTS.LocationID2)#
</cfif>
If this works then the function caller is not providing the LocationID2 argument and since your declaration does not require a value and defaults it to "", arguments.LocationID2 is not a number.
Copy link to clipboard
Copied
Thank you ! ! !
I follow the way you show me and solve my problem !
Another way, if i change the argument type to "numeric" can be avoid this kind error?
If i just need the result with numeric.