• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 546
  • Last Modified:

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
0
jayme9
Asked:
jayme9
  • 2
1 Solution
 
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
 
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

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now