wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Loading Progress Bar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Loading Progress Bar" Watch "Loading Progress Bar" New topic
Author

Loading Progress Bar

AnandEdward
Greenhorn

Joined: Mar 19, 2008
Posts: 8
Hi
Please give me a solution for this ,

Iam using a function for loading indicator.Actualy that function is to be given in "onLoad" function,but i need to use that function
in onClick event of Button.

Function used :

<script language="javascript">

var w3c=(document.getElementById)?true:false;
var ie=(document.all)?true:false;
var N=-1;
var bars=new Array();
var int;

function statusbar(){
createBar(320,15,'white',1,'black','darkblue',85,7,5);
}

function createBar(w,h,bgc,brdW,brdC,blkC,speed,blocks){
if(ie||w3c){
var t='<div style="position:relative; overflow:hidden; width:'+w+'px; height:'+h+'px; background-color:'+bgc+'; border-color:'+brdC+'; border-width:'+brdW+'px; border-style:solid; font-size:1px;">';
t+='<span id="blocks'+(++N)+'" style="left:-'+(h*2+1)+'px; position:absolute; font-size:1px">';
for(i=0;i<blocks;i++){
t+='<span style="background-color:'+blkC+'; left:-'+((h*i)+i)+'px; font-size:1px; position:absolute; width:'+h+'px; height:'+h+'px; '
t+=(ie)?'filter:alpha(opacity='+(100-i*(100/blocks))+')':'-Moz-opacity:'+((100-i*(100/blocks))/100);
t+='"></span>';
}
t+='</span></div>';
document.write("Plese Wait"+t);
var bA=(ie)?document.all['blocks'+N] ocument.getElementById('blocks'+N);
alert(bA.blocks=blocks);
bA.blocks=blocks;
bA.w=w;
bA.h=h;
bars[bars.length]=bA;
int=setInterval('startBar('+N+')',speed);

}

}

function startBar(bn){

var t=bars[bn];

t.style.left=((parseInt(t.style.left)+t.h+1-(t.blocks*t.h+t.blocks)>t.w)? -(t.h*2+1) : parseInt(t.style.left)+t.h+1)+'px';
}

function stop(){
window.clearInterval(int);
}
document.onstop=stop;

</script>

Problem:
Iam facing "object expected problem" when iam using the statusBar() function in onClick event of Button.
[ March 25, 2008: Message edited by: Bear Bibeault ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60740
    
  65

Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extermely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
You can not use document.write after the page load.

You either need to figure out how ti use innerHTML or appendChild() to get the elment on the page. OR you have the progress bar built on page load, you just hide it from view until you need it.

Eric
AnandEdward
Greenhorn

Joined: Mar 19, 2008
Posts: 8
Originally posted by Anand Edward:
Hi
Please give me a solution for this ,

I am using a function for loading indicator.Actualy that function is to be given in "onLoad" function,but i need to use that function
in onClick event of Button.

Function used :

Problem:
I am facing "object expected problem" when i am using the statusBar() function in onClick event of Button.




hi thank you for response, i am try to work on hide and show function, these function same thing problem occur in object required errorplease give me the solution
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I do not see anywhere where you have an element surrounding the loading bar with the display set to none. Than you should have a show function that sets the element to block.

If you are getting an object expected, that probably means you are not referencing the element's id correctly.

Eric
AnandEdward
Greenhorn

Joined: Mar 19, 2008
Posts: 8
hi
i am facing object request error in the block followingly



these function only making the error.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
As I said before you can not use document.write("Plese Wait"+t); after the page load. Are you calling the status method on the click evernt?

Eric
Pratheek Patel
Greenhorn

Joined: Feb 18, 2008
Posts: 14
Please refer to these sites:

http://forum.java.sun.com/thread.jspa?forumID=45&threadID=554223

http://www.coderanch.com/t/53812/Struts/animation-struts-while-searching

http://www.coderanch.com/t/53504/Struts/Show-progress-page-Struts
AnandEdward
Greenhorn

Joined: Mar 19, 2008
Posts: 8
hi Eric

i am using document.write("PleaseWait"+t) in after page load, it's showing the error in undefined is null or not an object.....
 
wood burning stoves
 
subject: Loading Progress Bar
 
Similar Threads
Cannot create MENU using Tiles
Accordion-Default value
Game Script??
using frameset
Pop up calendar Problem