Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF statement no functioning as expected

Status
Not open for further replies.

redoakhg

Programmer
Nov 30, 2006
38
US
Hi,

I am running the following if statement
Code:
<cfif getdealerupdates.dealerstatus IS "A"><cfset isactive = "1"><cfelse><cfset isactive = "0"></cfif>

It always returns isactive as 0.

I ran this right after the cfset noted above:
Code:
<cfoutput>Status: #getdealerupdates.dealerstatus# - Active Flag: #isactive# - Dealer ID: #getdealerupdates.dealernumber#</cfoutput><cfabort>
It returns: Status: A - Active Flag: 0 - Dealer ID: 028400

Any idea why when the status is obviously A, it returns 0?
 
The value of #dealerstatus# is not what you think it is. It could be something as simple as leading or trailing white space.

When values appear to be the same visually, the first thing to check is the len() of both values. If they are different, do a trim() to remove leading/trailing white space.

Code:
<cfoutput>
len dealerStatus = #Len(getdealerupdates.dealerstatus)#<br>
len "A" = #Len("A")#<br>
</cfoutput>

If that fails, check ascii values of the characters in each string. But in this case a simple trim() will probably do the trick.

----------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top