![]() Capt. Horatio T.P. Webb |
Parks -- Spring 2014 |
The general format of the progress bar is:
<progress id="some_id" max="100"></progress>
The default behavior of the above tag varies greeatly with the browser in use:
Minimal styling like this:
<form name="f1">
<progress id="pbar2" max="1.0" value="0.0" style="width:200px;height:20px;"></progress> <span id="bvalue"></span>
<input type="button" onClick="go2()" value="Start The Progress Bar">
</form>
produces:
The progress bar "value" attribute can be used to move the progress bar.
Further, when you specify the "max" attribute AND style a "width", the progress bar uses the "value" attribute
to move the progress bar.
It calculates "value"/"max" to determine the proportion of width that contains the bar color.
Below is the javascript timer to advance the progress bar.
function go2() { clearInterval (ptimer); pvalue=0.0; document.getElementById("pbar2").value=pvalue; document.getElementById("bvalue").innerHTML=pvalue; ptimer=setInterval("movep()","750"); } function movep() { pvalue=pvalue+.01; document.getElementById("pbar2").value=pvalue; document.getElementById("bvalue").innerHTML=pvalue.toFixed(2); if (pvalue > 1.0) { document.getElementById("bvalue").innerHTML="Done"; clearInterval (ptimer); } }
Meter allows the following attributes:
This is NOT implemented in any IE browser or Safari 5.1.7. In Chrome, Firefox and Opera: the bar changes to one of three colors:
If a value for "optimum" is specified, the range containing the optimum value is "green". Thus, the colors for the three ranges based on the "value" are:
This behavior is the reverse of the expected behavior:
low values are good (i.e., "green")
and
high values are bad (i.e., "red").
This is expected behavior -- that is green is good and occurs at the higher values.
Using the following meter tag:
<meter id="mymeter" min="10" max="100" low="40" high="70" optimum="25"></meter>