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" "">
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<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);
<input type="button"  id="d" value="0">