javascript - JS script doesn't work because of if else blocks -


i got banned , can no longer ask questions. in hopes rectify this, i'm editing down-voted threads block of text. intention never clog stackoverflow dumb questions or leech off community, did @ point. i've realized damage reading helpful thread how ask questions smart way. i'm hoping forgiveness community unintentional damage. thank you

i making simple prototype calculator game involves various damage calculations under specific conditions. because game involves precision , need calculations on spot, i've decided try convert actual app android phones using appsgeyser instead of going online dummy webpage i'd set basic form calculator.

however javascript skills basic, enough little project of mine. realized later on how awful syntax , why people have criticized it, since don't know how improve can ask people me out find error.

the if / else blocks fail , cannot see why.

<script> function showdiv() { var dmgpct = 0; var dmginc2 = 0.00; var arminc = 0.00; var critinc = 0.00; var critinc2 = 0; var splashdmg2 = 0; var splashinc = 0.00; var critchance = parseint(document.getelementbyid('critchance').value); var critdmg = document.getelementbyid('critdmg').value; var splashdmg = parseint(document.getelementbyid('splashdmg').value); var armor = document.getelementbyid('armortype').value; var armoramount = document.getelementbyid('armoramt').value; var damage = document.getelementbyid('dmgtype').value; var min = parseint(document.getelementbyid('mindmg').value); var max = parseint(document.getelementbyid('maxdmg').value); var dmginc = parseint(document.getelementbyid('dmginc').value); var dmg_done = math.floor(math.random() * (max - min + 1) + min); var try_crit = math.floor(math.random() * (100 - critchance + 1) + critchance);  document.getelementbyid('result').style.display = "block";  if(damage == "normal" && armor == "medium") { dmginc2 = parsefloat(dmginc * 0.01 + 1.50); arminc = parsefloat(dmginc2 - armoramount * 0.05); dmgpct = math.floor(dmg_done * arminc); document.getelementbyid('test').innerhtml = "damage roll: " + dmg_done; document.getelementbyid('test2').innerhtml = "damage boost: " + arminc.tofixed(2) + "%";     if (try_crit <= critchance)     {     critinc = parsefloat(critdmg * 0.01);     critinc2 = parseint(dmgpct*critinc);     splashinc = parsefloat(splashdmg * 0.01);     splashdmg2 = math.floor(critinc2 * splashinc);     document.getelementbyid('test3').innerhtml = "<b>critical damage: " + critinc2 + "</b>";     document.getelementbyid('test4').innerhtml = "<b>splash damage dealt: " + splashdmg2 + "</b>";     }     else     {     splashinc = parsefloat(splashdmg * 0.01);     splashdmg2 = math.floor(dmgpct * splashinc);     document.getelementbyid('test3').innerhtml = "<b>total damage dealt: " + dmgpct + "</b>";     document.getelementbyid('test4').innerhtml = "<b>splash damage dealt: " + splashdmg2 + "</b>";     } } else if(damage == "normal" && armor == "heavy") { dmginc2 = parsefloat(dmginc * 0.01 + 0.50); arminc = parsefloat(dmginc2 - armoramount * 0.05); dmgpct = math.floor(dmg_done * arminc); document.getelementbyid('test').innerhtml = "damage roll: " + dmg_done; document.getelementbyid('test2').innerhtml = "damage boost: " + arminc.tofixed(2) + "%";     if (try_crit <= critchance)     {     critinc = parsefloat(critdmg * 0.01);     critinc2 = parseint(dmgpct*critinc);     splashinc = parsefloat(splashdmg * 0.01);     splashdmg2 = math.floor(critinc2 * splashinc);     document.getelementbyid('test3').innerhtml = "<b>critical damage: " + critinc2 + "</b>";     document.getelementbyid('test4').innerhtml = "<b>splash damage dealt: " + splashdmg2 + "</b>";     }     else     {     splashinc = parsefloat(splashdmg * 0.01);     splashdmg2 = math.floor(dmgpct * splashinc);     document.getelementbyid('test3').innerhtml = "<b>total damage dealt: " + dmgpct + "</b>";     document.getelementbyid('test4').innerhtml = "<b>splash damage dealt: " + splashdmg2 + "</b>";     } } else if(damage == "normal" && armor == "light") { dmginc2 = parsefloat(dmginc * 0.01 + 1.00); arminc = parsefloat(dmginc2 - armoramount * 0.05); dmgpct = math.floor(dmg_done * arminc); document.getelementbyid('test').innerhtml = "damage roll: " + dmg_done; document.getelementbyid('test2').innerhtml = "damage boost: " + arminc.tofixed(2) + "%";     if (try_crit <= critchance)     {     critinc = parsefloat(critdmg * 0.01);     critinc2 = parseint(dmgpct*critinc);     splashinc = parsefloat(splashdmg * 0.01);     splashdmg2 = math.floor(critinc2 * splashinc);     document.getelementbyid('test3').innerhtml = "<b>critical damage: " + critinc2 + "</b>";     document.getelementbyid('test4').innerhtml = "<b>splash damage dealt: " + splashdmg2 + "</b>";     }     else     {     splashinc = parsefloat(splashdmg * 0.01);     splashdmg2 = math.floor(dmgpct * splashinc);     document.getelementbyid('test3').innerhtml = "<b>total damage dealt: " + dmgpct + "</b>";     document.getelementbyid('test4').innerhtml = "<b>splash damage dealt: " + splashdmg2 + "</b>";     } } </script> 

with formated , indented code, can see closing bracket missing @ end of function ...

and independently of layout, should improve it's readability, that's hell read.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -