<progress value="50" max="100" id=p1>50%</progress>
This progress bar has two main attributes. One is value and other one is maximum attribute. We can read the present value of the progress bar and we can set them to a new value.
<input type=button value='Increse' onClick='incr();'>
var v1=document.getElementById('p1').value;
Now we will set the new value by adding 10 to it.
document.getElementById("p1").value= v1 + 10;
The total function code is here.
<script language=JavaScript>
<!--
function incr() {
var v1=document.getElementById('p1').value;
document.getElementById("p1").value= v1 + 10;
}
//-->
</script>
Now each click of the button, the JavaScript function incr() will increase the progress bar value by 10.
<!doctype html public "-//w3c//dtd html 3.2//en">
<html>
<head>
<title> </title>
<script language=JavaScript>
<!--
function incr() {
var v1=document.getElementById('p1').value;
document.getElementById("p1").value= v1 + 10;
}
//-->
</script>
</head>
<body >
<progress value="50" max="100" id=p1>50%</progress>
<input type=button value='Increse' onClick='incr();'>
</body>
</html>
You can try to add one more button to decrease the value and also display a message saying end of the process ( when value equals to Max attribute )
23-02-2020 | |
Thanks a lot for the code. It worked for me. |
23-02-2020 | |
Thanks a lot for the code. It worked for me. |