alkorda
07-15-2011, 09:45 PM
Hey everyone,
I've got a div whose width I'm trying to modify when you click either the plus or minus button (incremental percentage-based).
The following is what I've written in an effort to accomplish this:
<script type="text/javascript">
function modify_jump(way) {
//check if we should increment or decrement
if (way == "inc") {
//two plus signs will increment our variable by one
jumpValue++;
} else if (way == "dec") {
//two minus signs will decrement our variable by one
jumpValue–;
}
var jumpWidth = "<div class='point_bar block' style='width: " + jumpValue + "%'></div>";
var jumpValue = "Total: " + jumpValue;
document.getElementById('jump_bar').innerHTML = jumpWidth;
document.getElementById('jump_value').innerHTML = jumpValue;
}
</script>
<div class="power_tracker">
<p>Force Jump</p>
<input type="button" value="-" id="jump_subtract" class="tracker_button block" onClick="modify_jump('dec')"></input>
<div id="jump_bar" class="bar_container block">
<div class="point_bar block"></div>
</div>
<input type="button" value="+" id="jump_add" class="tracker_button block" onClick="modify_jump('inc')"></input>
<br /><br />
<div id="jump_value" class="power_value">Total: </div>
</div>
I really know nothing about javascript, and am just starting out. Any and all help would be greatly appreciated, and if you need any other info, I'm more than happy to do so!
I've got a div whose width I'm trying to modify when you click either the plus or minus button (incremental percentage-based).
The following is what I've written in an effort to accomplish this:
<script type="text/javascript">
function modify_jump(way) {
//check if we should increment or decrement
if (way == "inc") {
//two plus signs will increment our variable by one
jumpValue++;
} else if (way == "dec") {
//two minus signs will decrement our variable by one
jumpValue–;
}
var jumpWidth = "<div class='point_bar block' style='width: " + jumpValue + "%'></div>";
var jumpValue = "Total: " + jumpValue;
document.getElementById('jump_bar').innerHTML = jumpWidth;
document.getElementById('jump_value').innerHTML = jumpValue;
}
</script>
<div class="power_tracker">
<p>Force Jump</p>
<input type="button" value="-" id="jump_subtract" class="tracker_button block" onClick="modify_jump('dec')"></input>
<div id="jump_bar" class="bar_container block">
<div class="point_bar block"></div>
</div>
<input type="button" value="+" id="jump_add" class="tracker_button block" onClick="modify_jump('inc')"></input>
<br /><br />
<div id="jump_value" class="power_value">Total: </div>
</div>
I really know nothing about javascript, and am just starting out. Any and all help would be greatly appreciated, and if you need any other info, I'm more than happy to do so!