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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

code error - fresh eyes needed 2

Status
Not open for further replies.

doyle9732

Programmer
Apr 12, 2002
185
CA
I'm doing a web based travel authorization. Part of the form deals with travelling to embargoed countries. In the error checking, I check if they choose the radio button 'embargoed' that the country they chose is indeed on the list of embargoed countries. That check works just fine. When I flip the logic around to ensure that the country entered matches the list the code fails to work?? I've looked at it and I can find no explanation for it, so perhaps some fresh eyes will immediately pick up what I'm obviously not getting. Error 1 works fine, Error 2 is triggered when you have for example: cuba and have the radio button 'embargoed' on.

<cfif (attributes.country IS "Libya" OR attributes.country IS "Cambodia" OR attributes.country IS "Cuba" OR attributes.country IS "North Korea" OR attributes.country IS "Vietnam" OR attributes.country IS "Nicaragua") AND attributes.TripDetail IS NOT "embargo">
<p align="center" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: Red; font-size: x-large;" font-size:="larger"><img src="images/stewardess.jpg" alt="" width="153" height="196" border="0"> </p>
<div align="center" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: large;">
Error 1 Oops! You have indicated that you are travelling to <cfoutput>#attributes.country#</cfoutput>, which is on the embargoed list. Use the browser 'back' button to go back and choose the radio button entitled 'embargo/other'.</div>

<!--- stop processing --->
<cfabort>
</cfif>

<cfif (attributes.country IS NOT "Libya" OR attributes.country IS NOT "Cambodia" OR attributes.country IS NOT "Cuba" OR attributes.country IS NOT "North Korea" OR attributes.country IS NOT "Vietnam" OR attributes.country IS NOT "Nicaragua") AND attributes.TripDetail IS "embargo">
<p align="center" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: Red; font-size: x-large;" font-size:="larger"><img src="images/stewardess.jpg" alt="" width="153" height="196" border="0"> </p>
<div align="center" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: large;">
Error 2 Oops! You have indicated that you are travelling to <cfoutput>#attributes.country#, which is not on the embargoed list (or it's not spelled correctly). Use the browser 'back' button to go back and choose the radio button appropriate for #attributes.country#</cfoutput>.</div>

<!--- stop processing --->
<cfabort>
</cfif>

thanks!
Stephanie
 
Right off the top of my head I would suggest replacing 'OR' in your second cfif statement with 'AND'.



Hope This Helps!

Ecobb
Beer Consumption Analyst

"My work is a game, a very serious game." - M.C. Escher
 
Replace your ors with ands in the the second example... but this method is better...

Code:
<cfif ListFind("Libya,Cambodia,Cuba,North Korea,Vietnam,Nicaragua",attributes.country)
  AND attributes.TripDetail IS NOT "embargo">
<p align="center" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: Red; font-size: x-large;" font-size:="larger"><img src="images/stewardess.jpg" alt="" width="153" height="196" border="0"> </p>
<div align="center" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: large;">
Error 1 Oops!  You have indicated that you are travelling to <cfoutput>#attributes.country#</cfoutput>, which is on the embargoed list.  Use the browser 'back' button to go back and choose the radio button entitled 'embargo/other'.</div>
    <!--- stop processing --->
    <cfabort>
</cfif>

<cfif not Listfind("Libya,Cambodia,Cuba,North Korea,Vietnam,Nicaragua",attributes.country)
  AND attributes.TripDetail IS "embargo">
<p align="center" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; color: Red; font-size: x-large;" font-size:="larger"><img src="images/stewardess.jpg" alt="" width="153" height="196" border="0"> </p>
<div align="center" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: large;">
Error 2 Oops!  You have indicated that you are travelling to <cfoutput>#attributes.country#, which is not on the embargoed list (or it's not spelled correctly).  Use the browser 'back' button to go back and choose the radio button appropriate for #attributes.country#</cfoutput>.</div>
    
    <!--- stop processing --->
    <cfabort>
</cfif>

ALFII.com
---------------------
If this post answered or helped to answer your question, please reply with such so that forum members with a similar question will know to use this advice.
 
It's empowering to know that after half a dozen years in the field, that I can get messed up on this kind of logic!! :-(

Now my eyes are refreshened and I can see the 'NOT' was throwing me off. I am actually going to change it to use the list - I originally had the embargoed countries hard coded, but later made them a table in the database - cause who knows who will be added or taken off a list like that!

you're both superstars!

thanks!
Stephanie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top