Solved

processing image on form submit

Posted on 2014-01-15
4
409 Views
Last Modified: 2014-01-16
Hello,

I need to show processing image on the page after the submit button is pressed.
I have an image on which i am calling java script function to submit the page.(document.form.submit)

Since there are around 7-8 tables in which the entries are inserted/updated which takes around 15-20 seconds.

Pages X -> document.form.submit -> Page Y.

Q1 -> How to show the processing message since the form is submitted and request is sent to server side.
Q2 -> How the X page comes to know that the processing image should hide?

Please suggest?
0
Comment
Question by:Rocking
  • 2
  • 2
4 Comments
 
LVL 27

Assisted Solution

by:rrz
rrz earned 500 total points
ID: 39782856
0
 

Author Comment

by:Rocking
ID: 39782930
If the document.from.submit is called then the request goes to the server side and server side processing starts.

I just can't understand then how can the code which is written after the from submit works?
0
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 39783595
>I just can't understand then how can the code which is written after the from submit works?
I am not sure. Let's use some test code. I am testing with the IE11 browser.
<html>
<head>
<title>FormTest</title>
   <style>
       .hidden { display: none; }
       .unhidden { display: block;}
   </style>
<script>
function submitForm(){
    var submitTime	= new Date().getTime();
	document.getElementById("submitTime").innerHTML = "submitted at " + submitTime;
	document.dataForm.submit();
    var submitImage = document.getElementById("submitImage");
    submitImage.className = 'hidden';
    var wait = document.getElementById("waitHTML");
    wait.className = 'unhidden';
	var returnTime	= new Date().getTime();
	document.getElementById("returnTime").innerHTML = "function return at " + returnTime;
}
</script>
</head>
<body>
<form name="dataForm"  method="post" action="result.jsp">
  <input type="text" name="firstName">
  <input type="text" name="lastName">
</form>
<div id="submitImage"> 
    <p><a  onclick="submitForm();">Submit</a></p>
</div>
<div id="waitHTML" class="hidden">
    Please wait until the process is complete.
	<div id="submitTime">   </div>
	<div id="returnTime">   </div>
</div>

</body>
</html>

Open in new window

and result.jsp is
<%@ page import="java.util.Date" %>
<html>
<body>
Request received at<%=new Date().getTime()%><br/>
<%
Thread.sleep(10000);  //mock processing
  out.print("Here is result");
%>
</body>
</html>

Open in new window

0
 

Author Comment

by:Rocking
ID: 39785783
the code is working,thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
varialbe initialization 11 37
MySQL  on Tomcat 8 67
ejb stateless example 2 18
What browser will run Java? 7 41
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question