Solved

How to dispaly decrement value in a page using Jsp

Posted on 2009-07-01
3
349 Views
Last Modified: 2012-05-07
Hi,

I want to dispaly the number that will decremnt one by one
for exmple starting number 10 decrease to  9 upto zero ...(like some downloading sites)
how to display this in java or jsp

Thanks
Sathish
0
Comment
  • 2
3 Comments
 
LVL 2

Expert Comment

by:mhaq_java
ID: 24753154
Use java script for it see following code.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script>
function fc() {
    if(c>=0){
        document.getElementById("dl").innerHTML = '<h3 style="font-size:24pt;" id="zeit">Still ' + c + ' seconds</h3>';
        c=c-1;        
        setTimeout("fc()", 1000);
    } else {
        document.getElementById("dl").innerHTML = 'Done';
    }
}
var c=10;
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
 
<body onload="javascript:fc();">
<div id="dl">.</div>
 
 
</body>
</html>

Open in new window

0
 
LVL 20

Author Comment

by:Sathish David Kumar N
ID: 24753201
Is it possible in java code ?
0
 
LVL 2

Accepted Solution

by:
mhaq_java earned 250 total points
ID: 24753299
you can also do it in recursion. just a example you can modify it accordingly. but if you want to use it in web. use JavaScript as most of the downloading site use java script
		try{
		int i=10;
		
		while(i>=0){
			System.out.print(i);
			i=i-1;
			Thread.sleep(1000);
			
		}
		
		System.out.print("Done");
		}catch(Exception e){
			e.printStackTrace();
			
		}

Open in new window

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
object methods vs static methods 2 97
java cigar challenge 58 210
love6 challenge java 31 133
iterator/ListIterator approach 17 24
When we purchase storage, we typically are advertised storage of 500GB, 1TB, 2TB and so on. However, when you actually install it into your computer, your 500GB HDD will actually show up as 465GB. Why? It has to do with the way people and computers…
Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

816 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now