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

Error Pages 1

Status
Not open for further replies.

anastasia

Programmer
Dec 13, 2000
111
GB
Hi, Does anyone know how to genertae an error page in Cold Fusion. I have done it ASP by refrencing within an if statement an errorform so that the errorform is displayed to the user only. However I am using the code within WML which may make it more tricky. The problem I am having is that the error is generated but so is everything else on the page which means that the user can progress to the next page without filling in certain fields.

Any ideas welcome.
 
I may not understand your application but it sounds like the visitor submits a page, you detect an error, display an error message, and then the rest of the page shows up. If you want the rest of the page to not show up under an error, you could do something like this.

<cfif errorCondition is true>

-------- Display error message and error code here --------

<cfelse>

-------Normal Page here -------
</cfif>

Another alternative is when you detect the error, just do a <cflocation> back to the previous page and pass a url variable that indicates an error condition like this.

<cfif errorExists>
<cflocation url=&quot;PreviousPage.cfm?errMsg=badData&quot;>
</cfif>

On the previous page, just check for the existence of a url variable called errMsg and then display any appropriate error message like this.

<cfif isdefined(&quot;url.errMsg&quot;)>
<cfif url.errMsg is &quot;badData&quot;>
--------- Display errror messsage --------
<cfelseif url.errMsg is &quot;blankFields&quot;>>
---------- Display other error message here ---------
</cfif>
</cfif>

Let me know if this isn't what you're looking for,
GJ
 
Thanks GunJack your code is ideal and works fine. I have used the CFLOCATION that you specified. It would be ideal if the CFLOCATION tag let you jump to a particular card within a Deck as with WML but I don't know if this is possible, it may not be? As at the moment it jumps to the first card in the deck which is hyperlinks it is the second card where the user enters there details and ideally this should be displayed back to the user.

If this is not possible that's fine the CFLOCATION works fine anyway the way it is.
 
Hey Anastasia,

If you want it to jump to a specific point in the page, you can just create an anchor and append the anchor reference on to the link like this.

On page1

<a name=&quot;card1&quot;>Card 1</a> .... html here...

<a name=&quot;card2&quot;>Card 2</a>.... html here..

On page 2

<cflocation url=&quot;page1.cfm?var1=1&var2=2##card1&quot;>

This should cause the browser to load page1.cfm and jump to the anchor point &quot;#card1&quot;. Just remember that anchor points are usually case sensitive.

Hope this helps,
GJ

 
GunJack Thanks for your expert help. The code you gae above works perfect. IDEAL!
 
GunJack Thanks for your expert help. The code you gave above works perfect.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top