CFLocation – URL redirection

There are times when it is handy to redirect to another CFM or page based upon search results. The issue I had this week was due to uninformed users not knowing which option to choose. So at the beginning of my queries I check to see if they are going down the right path or of they need to be redirected to another path. Rather than throwing an error message like “Hey dummy, you picked the wrong option” I merely redirect them to the correct path.

cfquery (logic to determine if the users selection is correct or not)
<cfif #queryname.recordcount# eq 0>
<cflocation url="newpage.cfm?xvar=xvalue&yvar=yvalue">
</cfif>

Another option would be to do a javascript confirm or CF9 Messagebox asking user to review their selections and continue/cancel.

Cup size   
Select size then click on coffee cup.
This entry was posted in Code, Coldfusion, Snippets. Bookmark the permalink.