jeudi 5 mars 2015

Trouble with Js/Html - Checkbox integer values for 'combat calculator' for game

Okay - I have been scouring for an answer to why my code isn't working.. and I just can't find it. I am assuming it comes from my checkbox value not returning as an integer, but I don't know how exactly to fix it..


http://ift.tt/17XgiBQ



<script type="text/javascript">
function update_value(chk_bx){
if(chk_bx.checked)
{
var a=-1;}
else{
var a=0;
}
document.getElementById('result').value =a;

}


Checkbox


Ignore most of my awful code (or give advice in general, if you're crazy awesome..) but take a look at how the calculator works, and you should quickly see that the 'archer field' doesn't work at all - this is due to it being my tester field and yeah, lemme direct you to the 'trouble code' spots..


See lines: 23,30, and 279-292


I want the values from the checked or unchecked box to return as integers, and then be applied to the calculator. An example of what it should do when FINISHED - Forest provides cover for units against archers, so if the FOREST box is checked, the integer would return -1 and apply a -1 to all archer units.


Please assist if you have the patience (complete code noob.. bet you noticed..) or point me in the right direction..


Aucun commentaire:

Enregistrer un commentaire