View Full Version : Event-based Progress Bar Help

04-15-2005, 08:53 PM
In the two Progressing the progress bar examples:

I can get the progress bar to work when I use-
<a href="javascript:incrCount(5)">Increase bar by 5%</a>

but, if I try-
<script>setCount(50) //set bar to 50%</script>
It displays the bar at 0%, not at 50%.

I've also tried-
<img src="myImage.jpg" height="2000" width="1000" onLoad="setCount(50)">
Which also displays the bar at 0%, not at 50%.

What am I doing wrong?

04-16-2005, 04:58 PM
What am I doing wrong?I can't imagine. The incrCount and decrCount function both call setCount, so replacing one of those working calls with a setCount call should work just fine.

Is there anything you're not telling us, such as error messages, etc.?

In future, please link to the script in question.


04-18-2005, 03:04 PM
No, there are no error messages.

Here is my test html that points to the "percent_bar.js".

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<script language="javascript" src="percent_bar.js"></script>
<a href="javascript:incrCount(25)">Click here to increment the bar by 25%</a>

<img src="myImage.jpg" height="2000" width="1000" onLoad="setCount(50)" >

04-18-2005, 03:06 PM
<script language="javascript" src="percent_bar.js"></script>

I'll just chip in here and say that as it stands, that's a violation of script usage terms. It should look like:

<script type="text/javascript" src="percent_bar.js">

Event-based progress bar- By Brian Gosselin at http://scriptasylum.com/bgaudiodr
Featured on DynamicDrive.com
For full source, visit http://www.dynamicdrive.com



04-18-2005, 05:10 PM
No, there are no error messages.Unless you've made some fairly significant modifications to the stock script, I certainly find errors in Firefox.

<script>setCount(50)</script>Missing type attribute aside, the script initialises the progress bar once the document has finished loading. Your call above will occur before this initialisation process is complete, thereby causing an error. If you want to start the bar at a value other than 0%, either call setCount from a load event listener, or modify the loaded variable declaration that appears after the "DO NOT EDIT BEYOND THIS POINT" comment.


04-18-2005, 05:22 PM
Yes, in its current "test" faze, I eliminated the 'rights' to simplify the code for this example. The 'rights' will be properly added when it goes live.

I'm thinking the problem might be inherent to some Event Handlers. I can get-
<img src="myImage.jpg" height="2000" width="1000" onLoad="setCount(50)" >
to work if I replace it with onClick or onMouseOut, but not onLoad, or onBlur, or onChange.

I know the 'onLoad' event handler is associated with both the 'window(frame)' and the 'image' object. Ideally, I'm looking for a triggered event other than a mouse triggered event.