Confirmation Msg AFTER Successful Submission

What is the best way to display a Confirmation Msg to a user after they have successfully submitted data through a record form?

1. Using Javascript function that uses the alert("Thank you. Successful submission.") and is executed during the onClick event of a form's submit button is a client-side event meaning that it executes prior to a submission.  This is similiar to the Delete Confirmation when you prompt the user "Are you sure you want to delete this record?"  What I really need is the following:

If form submission is successful, which I guess means no error, then display to user: "Successful Submission. Thank you."
If form submission is unsuccessful, which I guess means some type of error, then display to user: "Unsuccessful Submission.  Please try again."

I usually write in ASP.  Anyone ever deal with these types of Confirmation msgs making them appear after the fact?

Thank you,
Jayme
jayme9Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sajuksCommented:
You are on the right track. Using javascript is the best solutuion.
If you were delteing/updating using something like ) pseudocode)

sql = "delete from table where id = 1"
on error resume next
cmd.execute sql,

if err.Number <> 0 then
  ' Error - delete not performed.
  Response.Write "Problem in Deleting"
  Response.End
else
     Response.Write "Delete successful. " & recordsAffected & " records deleted."
end if

On just a form submission you cant've these error codes cos asp doesnt provide any return value.
Instead of doing a onclick submission do a
<form onsubmit ="retrun validate()">
<input type = "Submit">

the advantage of checking validn  in the onsubmit event is that if the return is false the page doesnt
get reloaded until the error is removed.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
k-doCommented:
Here's what I normally do using ASP:

(pseudocode)
Declare a variable called errMsg
Validate the form
   - If an item of the form is invalid, then errMsg = errMsg & "<li>Error Msg Text</li>"
If errMsg = "" then
   - form submission is valid/process contents
   - If error is encountered while processing the contents, then errMsg = errMsg & "<li>Error Msg Text</li>"
End If

If errMsg = "" then   ' Success message
   Response.Write("Your information has been successfully processed!")
Else                        ' Error message
   Response.Write("There were problems with your submission:<ul>"& errMsg &"</ul>Please try again.")
End If

(end pseudocode)

Hope this helps,

Keith
0
mohitrajCommented:
You can display the message after the form has been succesfully submitted. For this you need to have 2 asp files.

ASP File 1: The page where your form exists along with the Submit button. On click of the Submit button the page will be redirected to ASP File 2.

ASP File 2: This file will perform the Database operations. During this server side code you can track whether your data was succesfully saved to DB or not. ANd save the response in a global Server side variable. The HTml of this file will have a jaavscript body onload function such as
<body onload='displayMsg();'>. Now when the server side ASP code is executed then the HTml will be redered and the body onload function will be called. Access the server side variable in the JS function and dsplay the alert message accordingly.

ASP code:
<%
if <error> then
     serversideVar=0
else
     serversideVar=1
end if
%>


<SCRIPT LANGUAGE="JavaScript">
<!--

function displayMsg()
{
    if <%=serversideVar%> ==1
        alert("Successful Submission. Thank you.");
   else
         alert("Unsuccessful Submission.  Please try again.");
}
//-->
</SCRIPT>


Make sure the JS is included at the end of the same ASP page.
SHould u have any more problems so let me know.

Mohit Raj
0
sajuksCommented:
Thanks modulo. Happy Holidays.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.