Skip to main content
Known Participant
June 15, 2009
Question

How to clear error message ?

  • June 15, 2009
  • 1 reply
  • 2336 views

I have a cfform where I enter a part number for review. When submitted, I go the action page and perform a query to search using the form.partNumber. If the qry.recordcount is 0, I then do a url location to go back to the review page and display an error message, 'Part Number not found'. This works fine.

The problem is that the error message seems to be stuck in the url and whenever the review page is refreshed, the error message still displays.

How can I get the error message to display only when the error occurs, then clear and not display again ?

    This topic has been closed for replies.

    1 reply

    Inspiring
    June 15, 2009

    Let's say you have a line of code like this:

    <cfoutput>#ErrorMsg#</cfoutput>

    Just add a line after that to read:

    <cfset ErrorMsg = "">

    That will display it and then clear it for the next itteration.

    Known Participant
    June 15, 2009

    Thanks for the reply.

    Your suggestion looks like it will work.

    However, what if my error message is displayed in a popup window ? Whether I use javascript to validate or cfinput, the message is in a popup window, so my 'Part Number not found' message is in a popup window also (to be consistent), using javascript alert.

    Is there a way to use your method to override/prevent the popup from occuring more than once ?

    Thanks

    Inspiring
    June 15, 2009

    What triggers the pop-up? Just after the code that tests for the trigger add code to reset the trigger. If you are still having a problem show us the code that triggers the pop-up.