Need help to display a confirmation message after the form submission
Sam Saha
Ranch Hand
Joined: Jan 23, 2010
Posts: 89
posted
0
I am submitting a form. I am calling a servlet for from submission. If the form submission is successful I want to show up a confirmation message in the form itself. Can someone help me how to do that.
This is the code of my form in jsp:
<form name="feedbackForm" action="feedback" method="post">
<input type="hidden" id ="uRecid" name="userRecID" value="<%= request.getSession().getAttribute("USERRECID") %>" />
<input type="hidden" id ="appType" name="applicationType" value="AME" />
<input type="hidden" id ="fromFForm" name="fromFeedbackForm" value="Y" />
<div id="messageText">
<textarea id="feedbackText" name="message" rows="5" cols="70" class="dim" onkeypress="return imposeMaxLength(this, 3999);" onclick="javascript:changeClass(this.className, this.id);">The more specific your question or comment, the better service we can provide.</textarea>
</div>
<script>
$(document).ready(function(){
$('form[name=feedbackForm] input[type=submit]').click(function(e){
e.preventDefault();
$('form[name=feedbackForm]')[0].submit();
$('#feedbackText').val('');
});
});
</script>
<div id="message"></div>
<ul class="buttons">
<li class="secondary">
<input type="submit" value="Submit Feedback" />
</li>
</ul>
</form>
Ajax would be completely unnecessary and a poor way to handle things. Simple JSP can be used (and based upon another post that is exactly what was done).
That is very simple if you capture the onSubmit javascript even and show an alert message or unhide a div tag or use third party attractive messages...