Reputation: 59
I have a form that returns a list like this when submitted:
2009,9
I want to compare it to database pulled values but keep getting an error.
<cfif #FORM.month# eq #qGetDates.year#,#qGetDates.month#>
I know I probably have to cast it or convert it to a string for the comparison to work, how do I do this?
Thanks,
R.
Upvotes: 4
Views: 8442
Reputation: 2616
You are overusing #. Unless variables are inside quotation marks or a cfoutput block, you don't use # as a general rule.
Another rule: You must use quotes around strings (the comma in this case). You can also include variables in your strings with the rule above (use #) as seen in Henry's example.
<cfif #FORM.month# eq #qGetDates.year#,#qGetDates.month#>
should have # removed and the comma needs the string concatenated
<cfif FORM.month eq qGetDates.year & "," & qGetDates.month>
Or as Henry said
Upvotes: 2
Reputation: 24332
If you want to get the second value (a value after first comma), then
<cfset x = "2009,7">
<cfoutput>
#listGetAt(x,2)#
</cfoutput>
Upvotes: 1
Reputation: 32915
<cfif FORM.month eq "#qGetDates.year#,#qGetDates.month#">
or
<cfif compare(FORM.month, "#qGetDates.year#,#qGetDates.month#") EQ 0>
Upvotes: 13