<script>
function move() {
var dolar= document.getElementById("no1").value;
var elem = document.getElementById("myBar");
// var width = parseInt(dolar);
var width = 500;
var id = setInterval(frame, 5000);
function frame() {
width=parseInt(width)+parseInt(dolar);
if(width>=5000) {
clearInterval(id);
}
elem.style.width = width + 'px';
elem.innerHTML = width * 1 + 'px';
}
}
</script>
//the first input will increment in progress bar but the updated value would not get update in progress bar//
答案 0 :(得分:1)
Use this fiddle
I think its solve your problem...
function move() {
var dolar= document.getElementById("no1").value;
var elem = document.getElementById("myBar");
var width = 500;
var id = setInterval(frame, 5000);
function frame() {
width=parseInt(width)+parseInt(dolar);
if(width>=5000) {
clearInterval(id);
}
elem.style.width = width + 'px';
elem.innerHTML = width * 1 + 'px';
}
}
move();
答案 1 :(得分:0)
Issues I found in this code snippet are as follows:
To address above issues,
Below code should work fine:
<script>
function move() {
var dolar;
var elem = document.getElementById("myBar");
var width = 500;
var id = setInterval(frame, 5000);
function frame() {
dolar = document.getElementById("no1").value;
width = width + (!dolar ? 0 : dolar * 1);
if (width >= 5000) {
clearInterval(id);
}
elem.style.width = width + 'px';
elem.innerHTML = width + 'px';
}
}
move()
</script>