[Sheet Workers] Totaling Attributes and Syntax

So to start, here is the code, scroll down for a description of the actual problem. It's at the end of the code block anyway. <div style="text-align: center"> <img class="details-image" src="http://synography.com/wp-content/uploads/2018/01/ctrgbanner-03-1024x182.png" draggable="false" alt="" style="width: 75%; margin-top: 20px; margin-bottom: 15px;"><br> <!-- Set up the Tabs --> <input type="radio" class="sheet-tab sheet-tab1" name="attr_core-tab" value="1" title="Core Info" checked="checked"/>  <span class="sheet-tab sheet-tab1" style='line-height: 40px;'>CORE INFO</span> <input type="radio" class="sheet-tab sheet-tab2" name="attr_core-tab" value="2" title="Abilities" />  <span class="sheet-tab sheet-tab2" style='line-height: 20px;'>ABILITIES  GEAR</span> <input type="radio" class="sheet-tab sheet-tab3" name="attr_core-tab" value="3" title="Weapons" />  <span class="sheet-tab sheet-tab3" style='line-height: 40px;'>WEAPONS</span> <input type="radio" class="sheet-tab sheet-tab4" name="attr_core-tab" value="4" title="Health" />  <span class="sheet-tab sheet-tab4" style='line-height: 40px;'>HEALTH</span> <input type="radio" class="sheet-tab sheet-tab5" name="attr_core-tab" value="5" title="Inventory" />  <span class="sheet-tab sheet-tab5" style='line-height: 40px;'>INVENTORY</span> <input type="radio" class="sheet-tab sheet-tab6" name="attr_core-tab" value="6" title="Other" />  <span class="sheet-tab sheet-tab6" style='line-height: 40px;'>OTHER</span> <input type="radio" class="sheet-tab sheet-tab99" name="attr_core-tab" value="99" title="All" /> <span class="sheet-tab sheet-tab99" style='line-height: 40px;'>ALL</span> <!-- End Tab setup --> <div class="sheet-section-core"><!-- Core Tab --> <!-- Stuff on the tab --> <h1>Info & Stats</h1> <div class='sheet-2colrow'>   <div class='sheet-col border'> <table style="text-align: left"> <tr> <td>Character Level</td>  <td><input type="number" class="sheet-BigGear" name="attr_lvl" value="1" /></td>  <br> </tr> <tr> <td>Player Name</td> <td><input type="text" class="sheet-BigGear" name="attr_pname" value="" /></td> <br> </tr> <tr> <td>Character Name</td> <td><input type="text" class="sheet-BigGear" name="attr_cname" value="" /></td> <br> </tr> <tr> <td>Callsign (Optional)</td> <td><input type="text" class="sheet-BigGear" name="attr_nick" value="" /></td> <br> </tr> <tr> <td>Class </td> <td><select class="sheet-select" name="attr_class" style="width: 170px"> <option value="enforcer">Enforcer</option> <option value="officer">Officer</option> <option value="soldier">Soldier</option> <option value="scput">Scout</option> <option value="infiltrator">Infiltrator</option> <option value="mspecialist">Specialist (Medic)</option> <option value="hspecialist">Specialist (Hacker)</option> <option value="dspecialist">Specialist (Demoman)</option> </select></td> <br> </tr> </table>  </div> <div class='sheet-col border'> <table style="text-align: left"> <tr> <td>Religion</td> <td><input type="text" class="sheet-BigGear" name="attr_rel" value="" /></td> <br> </tr> <tr> <td>Age</td> <td><input type="text" class="sheet-BigGear" name="attr_age" value="" /></td> <br> </tr> <tr> <td>Gender </td> <td><select class="sheet-select" name="attr_gen"> <option value="m">Male</option> <option value="f">Female</option> </select></td> <br> </tr> <tr> <td>Weight</td> <td><input type="text" class="sheet-BigGear" name="attr_wei" value="" /></td> <br> </tr> <tr> <td>Height</td> <td><input type="text" class="sheet-BigGear" name="attr_hei" value="" /></td> <br> </tr> </table> <br> </div> </div> <br> <div class='sheet-3colrow'> <div class='sheet-col'> <table> <tr> <td>Strength </td> <td><input type="number" class="sheet-BigGear" name="attr_str" value="10" /></td> </tr> <tr> <td>Constitution </td> <td><input type="number" class="sheet-BigGear" name="attr_con" value="10" /></td> </tr> </table> </div> <div class='sheet-col'> <table> <tr> <td>Dexterity </td> <td><input type="number" class="sheet-BigGear" name="attr_dex" value="10" /></td> </tr> <tr> <td>Intelligence </td> <td><input type="number" class="sheet-BigGear" name="attr_int" value="10" /></td> </tr> </table> </div> <div class='sheet-col'> <table> <tr> <td>Wisdom </td> <td><input type="number" class="sheet-BigGear" name="attr_wis" value="10" /></td> </tr> <tr> <td>Charisma </td> <td><input type="number" class="sheet-BigGear" name="attr_cha" value="10" /></td> </tr> </table> </div> </div> <div> <h1>Inspiration</h1> <table class="sheet-tableII"> <td><input type="checkbox" name="insp-1" value="1"/><span></span></td> <td><input type="checkbox" name="insp-2" value="1"/><span></span></td> <td><input type="checkbox" name="insp-3" value="1"/><span></span></td> <td><input type="checkbox" name="insp-4" value="1"/><span></span></td> <td><input type="checkbox" name="insp-5" value="1"/><span></span></td> <td><input type="checkbox" name="insp-6" value="1"/><span></span></td> </table> </div> 1 Core tab </div> <div class="sheet-section-abilities"><!-- Edges Tab --> <!-- Stuff on the tab --> <h1>Abilities & Tech</h1> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="22px"> </th>       <th scope="col" width="180px">Name </th>       <th scope="col" width="80px">Modifier </th>       <th scope="col" width="100px">Location </th>       <th scope="col" width="400px">Notes </th>     </tr> </table> <fieldset class="repeating_equipment"> <table width="400" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="22px"><button type='roll' value='&{template:default}{{name=@{eqp_name} Roll}}{{Roll=[[ ?{Roll Type|Standard, 1d20 + @{eqp_mod}|Advantage, 2d20kh1 + @{eqp_mod}|Disadvantage, 2d20kl1 + @{eqp_mod}} ]]}}' name='roll_Normal'> </button></th>       <th scope="col" width="180px"><input type="text" class="sheet-BigGear" name="attr_eqp_name" value="" /></th>       <th scope="col" width="80px"><input type="number" name="attr_eqp_mod" value="0" /></th>       <th scope="col" width="100px"><select class="sheet-select" name="attr_eqp-pos" style="width: 88px"> <option value="null">N/A</option> <option value="vest">Vest</option> <option value="head">Head</option> <option value="arm">Arm</option> <option value="leg">Leg</option> <option value="worn">Worn</option> <option value="backpack">Backpack</option>     </select></th>       <th scope="col" width="400px"><textarea name="attr_eqp-note" value="note" style='vertical-align: text-top; width: 390px; height: 80px'>Notes</textarea> </th>     </tr> </table> </fieldset> 2 Abilities tab - sheet-section-abilities </div> <div class="sheet-section-weapons"><!-- Skills Tab --> <!-- Stuff on the tab --> <h1>Weapons</h1> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">     <tr>       <th scope="col" width="100px">Weapon </th>       <th scope="col" width="120px">Weapon Name </th>       <th scope="col" width="60px">Mag Size </th>       <th scope="col" width="60px">Mag Current </th>       <th scope="col" width="80px">Calliber </th>       <th scope="col" width="70px">Weight (Pounds)</th>       <th scope="col" width="200px">Notes </th>     </tr>     <tr>       <th scope="col" width="100px">Primary </th>       <th scope="col" width="120px"><input type="text" class="sheet-BigGear" name="attr_pri_name" value="" style='width: 110px;'/></th>       <th scope="col" width="60px"><input type="number" name="attr_pri_magsize" value="0"/></th>       <th scope="col" width="60px"><input type="number" name="attr_pri_cursize" value="0" readonly/></th>       <th scope="col" width="80px"><select class="gun-select" name="attr_pri_cal" style="width: 70px"> <option value="556">5.56</option> <option value="762">7.62</option> <option value="545">5.45</option> <option value="9mm">9mm</option> <option value="45acp">.45acp</option> <option value="357">.357</option> <option value="50">.50</option> <option value="other">Other</option>     </select></th> <th scope="col" width="70px"><input type="number" name="attr_pri_weight" value="0" style="width: 50px"/></th>       <th scope="col" width="200px"><textarea name="attr_pri_notes" value="note" style='vertical-align: text-top; width: 190px; height: 42px'>Notes</textarea></th>     </tr> <tr>       <th scope="col" width="100px">Secondary </th>       <th scope="col" width="120px"><input type="text" class="sheet-BigGear" name="attr_sec_name" value="" style='width: 110px;'/></th>       <th scope="col" width="60px"><input type="number" name="attr_sec_magsize" value="0"/></th>       <th scope="col" width="60px"><input type="number" name="attr_sec_cursize" value="0" readonly/></th>       <th scope="col" width="80px"><select class="gun-select" name="attr_sec_cal" style="width: 70px"> <option value="9mm">9mm</option> <option value="556">5.56</option> <option value="762">7.62</option> <option value="545">5.45</option> <option value="45acp">.45acp</option> <option value="357">.357</option> <option value="50">.50</option> <option value="other">Other</option>     </select></th> <th scope="col" width="70px"><input type="number" name="attr_sec_weight" value="0" style="width: 50px"/></th>       <th scope="col" width="200px"><textarea name="attr_sec_notes" value="note" style='vertical-align: text-top; width: 190px; height: 42px'>Notes</textarea></th>     </tr>     <tr>       <th scope="col" width="120px">Other </th>       <th scope="col" width="120px"><input type="text" class="sheet-BigGear" name="attr_other_name" value="" style='width: 110px;'/></th>       <th scope="col" width="60px"><input type="number" name="attr_other_magsize" value="0"/></th>       <th scope="col" width="60px"><input type="number" name="attr_other_cursize" value="0" readonly/></th>       <th scope="col" width="80px"><select class="gun-select" name="attr_other_cal" style="width: 70px"> <option value="other">Other</option> <option value="556">5.56</option> <option value="762">7.62</option> <option value="545">5.45</option> <option value="9mm">9mm</option> <option value="45acp">.45acp</option> <option value="357">.357</option> <option value="50">.50</option>     </select></th> <th scope="col" width="70px"><input type="number" name="attr_other_weight" value="0" style="width: 50px"/></th>       <th scope="col" width="200px"><textarea name="attr_other_notes" value="note" style='vertical-align: text-top; width: 190px; height: 42px'>Notes</textarea></th>     </tr> </table> <table width="200" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="60px">9mm </th>       <th scope="col" width="60px">.45 </th>       <th scope="col" width="60px">.357 </th>       <th scope="col" width="60px">5.45 </th>       <th scope="col" width="60px">5.56 </th>       <th scope="col" width="60px">7.62 </th>       <th scope="col" width="60px">.50 </th>     </tr>     <tr>       <td><input type="number" name="attr_ammo_9mm" value="0" style="width: 56px"/> </td>       <td><input type="number" name="attr_ammo_357" value="0" style="width: 56px"/> </td>       <td><input type="number" name="attr_ammo_45" value="0" style="width: 56px"/> </td>       <td><input type="number" name="attr_ammo_545" value="0" style="width: 56px"/> </td>       <td><input type="number" name="attr_ammo_556" value="0" style="width: 56px"/> </td>       <td><input type="number" name="attr_ammo_762" value="0" style="width: 56px"/> </td>       <td><input type="number" name="attr_ammo_50" value="0" style="width: 56px"/> </td>     </tr>   </tbody> </table> <hr> 3 Weapons tab - sheet-section-weapons </div> <div class="sheet-section-health"><!-- gear Tab --> <!-- Stuff on the tab --> <h1>Damage</h1> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="80px">Location </th>       <th scope="col" width="90px">Type </th>       <th scope="col" width="80px">Severity </th>       <th scope="col" width="55px">Treated </th>       <th scope="col" width="280px">Notes </th>     </tr> </table> <fieldset class="repeating_damage"> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="80px"><select class="sheet-select" name="attr_dmg-pos"> <option value="head">Head</option> <option value="torso">Torso</option> <option value="larm">Left Arm</option> <option value="rarm">Right Arm</option> <option value="lleg">Left Leg</option> <option value="rleg">Right Leg</option> <option value="other">Other</option> </select></th>       <th scope="col" width="90px"><select class="sheet-select" name="attr_dmg-type" style="width: 90px"> <option value="piercing">Piercing</option> <option value="bludeoning">Bludeoning</option> <option value="slashing">Slashing</option> <option value="acid">Acid</option> <option value="frost">Frost</option> <option value="fire">Fire</option> <option value="lightning">Lightning</option> <option value="poison">Poison</option> <option value="phsycic">Psychic</option> <option value="thunder">Thunder</option> </select></th>       <th scope="col" width="80px"><select class="sheet-select" name="attr_dmg-sev"> <option value="none">None</option> <option value="min">Minor</option> <option value="maj">Major</option> <option value="mor">Mortal</option> </select></th>       <th scope="col" width="55px"><input type="checkbox" name="attr_treated" value="0" checked="false"></th>       <th scope="col" width="280px"><textarea name="attr_dmg-note" value="note" style='width: 258px; height: 44px'>Notes</textarea></th>     </tr> </table> </fieldset> 4 Health tab - sheet-section-health </div> <div class="sheet-section-inventory"><!-- arcanum Tab --> <!-- Stuff on the tab --> <h1>Items</h1> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="60px">UNIFORM </th>       <th scope="col" width="60px">VEST </th>       <th scope="col" width="60px">BACKPACK </th>     </tr> </table> <table width="500" border="1" cellspacing="6px" cellpadding="6px" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="60px"><input type="checkbox" class="" name="attr_equip_uniform" value="1" title="Clothing" checked="true"/></th>       <th scope="col" width="60px"><input type="checkbox" class="" name="attr_equip_vest" value="1" title="Vest" checked="true"/></th>       <th scope="col" width="60px"><input type="checkbox" class="" name="attr_equip_backpack" value="1" title="Bakcpack" checked="true"/></th>     </tr> </table> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="180px">Item </th>       <th scope="col" width="90px">Weight </th>       <th scope="col" width="70px">Quantity </th>       <th scope="col" width="70px">Equipped </th>       <th scope="col" width="80px">Location </th>       <th scope="col" width="280px">Notes </th>     </tr> </table> <fieldset class="repeating_inventory"> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="180px"><input type="text" name="attr_item_name" style="width: 180px" class="sheet-skill-label"></th>       <th scope="col" width="90px"><input type="number" name="attr_item_weight" style="width: 80px" class="sheet-skill-value"></th>       <th scope="col" width="70px"><input type="number" name="attr_item_quantity" style="width: 60px" class="sheet-skill-value"></th>       <th scope="col" width="70px"><input type="checkbox" name="attr_item_carrying" value="1" checked="true"></th>       <th scope="col" width="80px">   <select name="attr_item_location" style="width: 82px">       <option value="uniform">Uniform</option>       <option value="vest">Vest</option>       <option value="backpack">Backpack</option>   </select></th> <th scope="col" width="280px"><textarea name="attr_item_note" value="note" style='width: 258px; height: 44px'>Notes</textarea></th>     </tr> </table> </fieldset> <div class="weighttotal"> <span class="label">TOTAL WEIGHT</span> <input type="text" name="attr_weight_total" style="width: 80px" value="0" readonly> lbs </div> 5 Inventory tab - sheet-section-inventory </div> <div class="sheet-section-other"><!-- Journal Tab --> <!-- Stuff on the tab --> <h1>Other Items & Notes</h1> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="200px">Item </th>       <th scope="col" width="100px">Location </th>       <th scope="col" width="500px">Notes </th>     </tr> </table> <fieldset class="repeating_notes"> <table width="500" border="1" style="margin:1em auto; table-layout: fixed">   <tbody>     <tr>       <th scope="col" width="200px"><input type="text" name="attr_item_name" style="width: 180px" class="sheet-skill-label"></th>       <th scope="col" width="100px">   <select name="attr_item_location" style="width: 82px">       <option value="uniform">Uniform</option>       <option value="vest">Vest</option>       <option value="backpack">Backpack</option>   </select></th> <th scope="col" width="500px"><textarea name="attr_item_note" value="note" style='width: 490px; height: 44px'>Notes</textarea></th>     </tr> </table> </fieldset> 6 Other tab - sheet-section-other </div> </div> <script type="text/worker"> on("change:equip_uniform change:equip_vest change:equip_backpack change:repeating_inventory:item_weight change:repeating_inventory:item_carrying change:repeating_inventory:item_location change:repeating_inventory:item_quantity change:ammo_9mm change:ammo_357 change:ammo_45 change:ammo_545 change:ammo_556 change:ammo_762 change:ammo_50 remove:repeating_inventory", function() { getSectionIDs("repeating_inventory", function(IDArray) { var fieldNames = [];         for (var i=0; i < IDArray.length; i++) { fieldNames.push("repeating_inventory_" + IDArray[i] + "_item_weight");           fieldNames.push("repeating_inventory_" + IDArray[i] + "_item_quantity");           fieldNames.push("repeating_inventory_" + IDArray[i] + "_item_carrying");           fieldNames.push("repeating_inventory_" + IDArray[i] + "_item_location"); }     fieldNames.push("equip_uniform");           fieldNames.push("equip_vest");           fieldNames.push("equip_backpack"); fieldNames.push("ammo_9mm");       fieldNames.push("ammo_357");       fieldNames.push("ammo_45");        fieldNames.push("ammo_545");       fieldNames.push("ammo_556");       fieldNames.push("ammo_762");       fieldNames.push("ammo_50");        fieldNames.push("pri_weight");       fieldNames.push("sec_weight");       fieldNames.push("other_weight"); console.log("Start of the script after gathering field names----------------------------------"); var total = 0;         var per = 0; var equipped = 0;         getAttrs(fieldNames, function(values) {             for (var i=0; i < IDArray.length; i++) {                 var uniform_enabled = values["equip_uniform"]; var vest_enabled = values["equip_vest"]; var backpack_enabled = values["equip_backpack"]; console.log("here are the values of the enabled clothing items"); console.log("uniform:" + uniform_enabled + " backpack:" + backpack_enabled + " vest:" + vest_enabled); var location = values["repeating_inventory_" + IDArray[i] + "_item_location"]; var equipped = values["repeating_inventory_" + IDArray[i] + "_item_carrying"]*1; if(backpack_enabled != 0)  { console.log("inside of backpack_enabled loop with this as the value:"+backpack_enabled); console.log("where is the item though?:"+location); if (location == "backpack") { console.log("inside of location == backpack loop with this as the value:"+location); if (equipped){ per = 0; per = values["repeating_inventory_" + IDArray[i] + "_item_weight"]*1||0; total += per*values["repeating_inventory_" + IDArray[i] + "_item_quantity"]||0; } } }  if (vest_enabled != 0)  { console.log("inside of vest_enabled loop with this as the value:"+vest_enabled); console.log("where is the item though?:"+location); if (location == "vest") { console.log("inside of location == backpack loop with this as the value:"+location); if (equipped){ per = 0; per = values["repeating_inventory_" + IDArray[i] + "_item_weight"]*1||0; total += per*values["repeating_inventory_" + IDArray[i] + "_item_quantity"]||0; } } }  if (uniform_enabled != 0) { console.log("inside of uniform_enabled loop with this as the value:"+uniform_enabled); console.log("where is the item though?:"+location); if (location == "uniform") { console.log("inside of location == backpack loop with this as the value:"+location); if (equipped){ per = 0; per = values["repeating_inventory_" + IDArray[i] + "_item_weight"]*1||0; total += per*values["repeating_inventory_" + IDArray[i] + "_item_quantity"]||0; } } } } var primary_weight = values["pri_weight"]*1||0; var secondary_weight = values["sec_weight"]*1||0; var otherItem_weight = values["other_weight"]*1||0; total += (primary_weight+secondary_weight+otherItem_weight); //here is the code block in question /* var 9mm_count = values["ammo_9mm"]*1||0; var 357_count = values["ammo_357"]*1||0; var 45_count = values["ammo_45"]*1||0; var 545_count = values["ammo_545"]*1||0; var 556_count = values["ammo_556"]*1||0; var 762_count = values["ammo_762"]*1||0; var 50_count = values["ammo_50"]*1||0; console.log("9mm_count:" + 9mm_count + " 357_count:" + 357_count + " 45_count:" + 45_count + " 545_count:" + 545_count + " 556_count:" + 556_count + " 762_count:" + 762_count + " 50_count:" + 50_count); total += ((9mm_count*0.03)+(357_count*0.05)+(45_count*0.06)+(545_count*0.03)+(556_count*0.04)+(762_count*0.07)+(50_count*0.25)); */ setAttrs({ "weight_total": total });         }); }); }); </script> When uncommenting the code in question, I stop getting console log responses and no errors appear to show up in the log. I'm not sure if it's a synatax error, or maybe my eyes are just blind to it for staring at it too long. I tried to implement them the same way I did var primary_weight = values["pri_weight"]*1||0; var secondary_weight = values["sec_weight"]*1||0; var otherItem_weight = values["other_weight"]*1||0; but it doesn't appear to be working as I thought. I don't think it's a very big issue, considering it's just on the brink of working and I'm able to isolate and reproduce the problem. I'm guessing it's some form of script error considering the log stops making outputs.
1515828351

Edited 1515828383
Scott C.
Pro
API Scripter
Run it through the closure compiler to see if there is a syntax error. https://closure-compiler.appspot.com/home
1515828503
G G
Pro
I havent looked through your code (still waking up), but I'd do the snippet at the end differently: var primary_weight = parseInt(values["pri_weight"])||0; var secondary_weight = parseInt(values["sec_weight"])||0; var otherItem_weight = parseInt(values["other_weight"])||0;
var primary_weight = parseInt(values["pri_weight"])||0; var secondary_weight = parseInt(values["sec_weight"])||0; var otherItem_weight = parseInt(values["other_weight"])||0; var 9mm_count = parseInt(values["ammo_9mm"])||0; var 357_count = parseInt(values["ammo_357"])||0; var 45_count = parseInt(values["ammo_45"])||0; var 545_count = parseInt(values["ammo_545"])||0; var 556_count = parseInt(values["ammo_556"])||0; var 762_count = parseInt(values["ammo_762"])||0; var 50_count = parseInt(values["ammo_50"])||0; console.log("9mm_count:" + 9mm_count + " 357_count:" + 357_count + " 45_count:" + 45_count + " 545_count:" + 545_count + " 556_count:" + 556_count + " 762_count:" + 762_count + " 50_count:" + 50_count); total += (primary_weight+secondary_weight+otherItem_weight); total += ((9mm_count*0.03)+(357_count*0.05)+(45_count*0.06)+(545_count*0.03)+(556_count*0.04)+(762_count*0.07)+(50_count*0.25)); So I checked for syntax, no errors come up except for the fact that it's not a full html page with a head and body. I changed the parsing of the values. It doesn't seem to be working either way. To further explain the attribute is only mentioned a few times, so for example let's say just ammo_9mm. ... <td><input type="number" name="attr_ ammo_9mm " value="0" style="width: 56px"/> </td> ... Here's the input for the attribute, easy enough now lets go down the line... ... var fieldNames = [];         for (var i=0; i < IDArray.length; i++) { ... } ...           fieldNames.push("equip_backpack"); fieldNames.push("ammo_9mm");       fieldNames.push("pri_weight"); ...         getAttrs( fieldNames , function(values) { ... ammo_9mm is added to fieldNames and run through the getAttrs function. Should now be recognizable inside. Way down the line after running through all the other items in inventory ... var 9mm_count = parseInt(values[" ammo_9mm "])||0; ... Parse the count of 9mm bullets into an int, then call it 9mm_count ... console.log("9mm_count:" + 9mm_count ); total += ( 9mm_count *0.03); ... Add to the total weight based on the int multiplied by it's weight in lbs and add to total. (If theres a math problem here with adding the total, I've tested it with and without adding the total, the only thing that seems to affect it is parsing the integer from the value ammo_9mm . I'm very very perplexed.
1515907714
G G
Pro
Can variables start with a number? i cant say for javascript, but other languages I know, you must always start variable names with a letter. So 9mm_count is bad, count_9mm is fine.
Damn , that was obscure, thanks got it working now. That was it. Note to self Don't start variables with a number or probably anything that isn't a letter. I think underscore might be valid but I'll stick to at least starting with a letter for now on.