Respected,
Requirement is when body loaded there must be 1 increment in the variable. and total number of loading the body display on the button (document.button name.value=variable name)

The onload event is more appropriately applied to the window and is deprecated on the body. You may assign code to the event with the syntax window.onload=

Here's a simple demo, that will increment the value of n for 10 (or 10seconds) and then it will stop.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>DEMO</title>
<script type="text/javascript">
function loadingSequence(counter) {
var n= setTimeout('loadingSequence(1)',1000);
x = 10;
document.getElementById('d').value = ((n -1) * counter);
if ( n > x )  
{ clearTimeout(n);  
  }
} window.onload = loadingSequence(1);
</script> 
</head>
<body>
<div>
<input type="button"  id="d" value="0">
</div>
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.