I am trying to create a dynamic bar in HTML using javascript.
I have create the button but cannot seem to pass the value over to the progress bar.
Can someone please help me? thanks!
<button onclick="increase()">Add</button>
<button onclick="decrease()">Minus</button>
<input type="text" id="tb">
<script type="text/javascript">
var value = 0 document.getElementById("tb").value = value;
function increase(){
this.value = value + 1; document.getElementById("tb").value=value;
}
function decrease(){
this.value = value - 1; document.getElementById("tb").value=value;
}
document.write("<div class='meter'><span style='width: 30%'></span> </div>");
document.write("<input type='text' id=\"tb\">"+value +" </input>");
</script>
It’d be easier to do this in jQuery, but here it goes with POJS:
js:
document.writeis janky, so I ditched that & put the bar in the markup.html:
css:
fiddle: http://jsfiddle.net/sw95b/