|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
i must be really dumb.
i am checking against a query output to see whether a certain field is SOFT or INT <cfoutput query="getD1"> <cfif getD1.Type IS 'SOFT'> <cfset crap = 0> <cfelse> <cfset crap = 1> </cfif> #crap#<p></p> </cfoutput> for some reason, it always assigns crap as 1 even though there are several INTs in the output. does anyone know why? |
|
#2
|
|||
|
|||
|
Falcon --
What do you get when you output #getD1.Type# that? |
|
#3
|
||||
|
||||
|
is your query set to get a certain record from the database or just a general number of records?
|
|
#4
|
||||
|
||||
|
also i ran into some of the similar problems like you have there when i named the query, try using just type instead of getD1.type....
|
|
#5
|
|||
|
|||
|
You could try using trim() around that, as any extra spaces that you don't notice would make the condition fail.
And this is a nice example of why not being thorough in your conditionals can cause big headaches. You may find this approach helps reduce problems like this: <cfif getD1.Type IS 'SOFT'> <cfset crap = 0> <cfelseif getD1.Type IS 'INT'> <cfset crap = 1> <cfelse> <cfset crap = "Neither condition was met!! Type is #getD1.Type#"> </cfif> #crap#<p></p>
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#6
|
|||
|
|||
|
if i put
#type# -#crap#<p></p> in that block. this is what i get SOFT -1 SOFT -1 SOFT -1 INT -1 INT -1 SOFT -1 SOFT -1 SOFT -1 SOFT -1 SOFT -1 SOFT -1 INT -1 |
|
#7
|
|||
|
|||
|
TRIM() solved the problem. damn.. thanks Kiteless and everyone
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > <Cfif> question |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|