title: I can not make all the Javascript calculation to work together for the total
body: <p>I need to get the amount due when someone selects different options from different products. The calculation is right for the first checkbox until I select the second one which reset the calculation for the first box to zero.
  Here's part of the code and on <a href="https://jsfiddle.net/samsh/ad1t3gmv/5/" rel="nofollow noreferrer">JSFiddle</a> as well. Sorry, the code is a bit long. I tried to make it shorter, but every time I messed up the code.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>"use strict";
  
  var total = 0;
  var price = 0;
  
  var amountDue = document.getElementById("amountDue");
  
  var selectOptions = document.getElementById("selectDesktop");
  var selectOptionsPlus = document.getElementById("selectDesktopPlus");
  
  
  function calculateTotal() {
      var desktopAddOn = document.getElementById("desktops");
      var desktopPlusAddOn = document.getElementById("desktopsPlus");
  
      var wirelessCardAddOn = document.getElementById("wirelessCard");
      var extraMemoryAddOn = document.getElementById("extraMemory");
      var speakersAddOn = document.getElementById("speakers");
      var surgeProtectorsAddOn = document.getElementById("surgeProtectors");
      var flashDriveAddOn = document.getElementById("flashDrive");
      var addSSDAddOn = document.getElementById("addSSD");
  
      var dTotal = 0;
  
      if (desktopAddOn.checked) {
          dTotal += 185;
  
          var iNumberofItems = selectOptions.options[selectOptions.selectedIndex].value;
          dTotal = Math.round(dTotal * iNumberofItems);
      }
  
      if (desktopPlusAddOn.checked) {
          dTotal += 85;
  
          var iNumberofItemsPlus = selectOptionsPlus.options[selectOptionsPlus.selectedIndex].value;
          dTotal = Math.round(dTotal * iNumberofItemsPlus);
      }
  
      if (wirelessCardAddOn.checked) {
          dTotal += 30;
      }
      if (extraMemoryAddOn.checked) {
          dTotal += 50;
      }
      if (speakersAddOn.checked) {
          dTotal += 30;
      }
      if (surgeProtectorsAddOn.checked) {
          dTotal += 5;
      }
      if (flashDriveAddOn.checked) {
          dTotal += 30;
      }
      if (addSSDAddOn.checked) {
          dTotal += 30;
      }
      amountDue.innerHTML = dTotal;
  }
  
  document.getElementById("desktops").addEventListener("change", function () {
      selectOptions.value = 1;
      calculateTotal();
  });
  
  document.getElementById("desktopsPlus").addEventListener("change", function () {
      selectOptions.value = 1;
      calculateTotal();
  });
  
  document.getElementById("wirelessCard").addEventListener("change", calculateTotal)
  selectOptions.addEventListener('change', calculateTotal);
  
  document.getElementById("extraMemory").addEventListener("change", calculateTotal)
  selectOptions.addEventListener('change', calculateTotal);
  
  document.getElementById("speakers").addEventListener("change", calculateTotal)
  selectOptions.addEventListener('change', calculateTotal);
  
  document.getElementById("surgeProtectors").addEventListener("change", calculateTotal)
  selectOptions.addEventListener('change', calculateTotal);
  
  document.getElementById("flashDrive").addEventListener("change", calculateTotal)
  selectOptions.addEventListener('change', calculateTotal);
  
  document.getElementById("addSSD").addEventListener("change", calculateTotal)
  selectOptions.addEventListener('change', calculateTotal);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>            &lt;div class="form-row products"&gt;
                  &lt;div class="form-group"&gt;
                      &lt;label for="chkYes1"&gt;
                          &lt;input type="checkbox" id="desktops" name="" value="desktops" /&gt;
                          Desktops (1-9 Units) - $185.00 &amp;nbsp;&amp;nbsp;
                      &lt;/label&gt;
                  &lt;/div&gt;
                  &lt;select id="selectDesktop" name="" class="form-control-sm"&gt;
                      &lt;option value="0"&gt;0&lt;/option&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt;
                      &lt;option value="4"&gt;4&lt;/option&gt;
                      &lt;option value="5"&gt;5&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
  
              &lt;!--  Desktops (10+ Units) --&gt;
              &lt;div class="form-row products"&gt;
                  &lt;div class="form-group "&gt;
                      &lt;label for="chkYes2"&gt;
                          &lt;input type="checkbox" id="desktopsPlus" name="" value="desktopsPlus" /&gt;
                          Desktops (10+ Units) - $85.00 &amp;nbsp;&amp;nbsp;
                      &lt;/label&gt;
                  &lt;/div&gt;
                  &lt;select id="selectDesktopPlus" name="" class="form-control-sm"&gt;
                      &lt;option value="0"&gt;0&lt;/option&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt;
                      &lt;option value="4"&gt;4&lt;/option&gt;
                      &lt;option value="5"&gt;5&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
  
              &lt;!-- Laptops (1-9 Units) --&gt;
              &lt;div class="form-row products"&gt;
                  &lt;div class="form-group "&gt;
                      &lt;label for="chkYes3"&gt;
                          &lt;input type="checkbox" id="laptops" name="" value="laptops" /&gt;
                          Laptops (1-9 Units) - $250.00 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
                      &lt;/label&gt;
                  &lt;/div&gt;
                  &lt;select id="selectbasic" name="selectbasic" class="form-control-sm"&gt;
                      &lt;option value="0"&gt;0&lt;/option&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt;
                      &lt;option value="4"&gt;4&lt;/option&gt;
                      &lt;option value="5"&gt;5&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
  
              &lt;!-- Laptops (10+ Units) --&gt;
              &lt;div class="form-row products"&gt;
                  &lt;div class="form-group "&gt;
                      &lt;label for="chkYes4"&gt;
                          &lt;input type="checkbox" id="laptopsPlus" name="" value="laptopsPlus"/&gt;
                          Laptops (10+ Units) - $125.00 &amp;nbsp;&amp;nbsp;
                      &lt;/label&gt;
                  &lt;/div&gt;
                  &lt;select id="selectbasic" name="selectbasic" class="form-control-sm"&gt;
                      &lt;option value="0"&gt;0&lt;/option&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt;
                      &lt;option value="4"&gt;4&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
  
              &lt;!-- Microsoft Surface --&gt;
              &lt;div class="form-row products"&gt;
                  &lt;div class="form-group "&gt;
                      &lt;label for="chkYes5"&gt;
                          &lt;input type="checkbox" id="msSurface" name="" value="msSurface" /&gt;
                          Microsoft Surface - $199.00 &amp;emsp;&amp;nbsp;
                      &lt;/label&gt;
                  &lt;/div&gt;
                  &lt;select id="selectbasic" name="selectbasic" class="form-control-sm"&gt;
                      &lt;option value="0"&gt;0&lt;/option&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt;
                      &lt;option value="4"&gt;4&lt;/option&gt;
                      &lt;option value="5"&gt;5&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
  
              &lt;!-- Apple iPad --&gt;
              &lt;div class="form-row products"&gt;
                  &lt;div class="form-group "&gt;
                      &lt;label for="chkYes6"&gt;
                          &lt;input type="checkbox" id="appleIpad" name="" value="appleIpad" /&gt;
                          Apple iPad - $85.00 &amp;emsp;&amp;emsp;&amp;emsp;&amp;emsp;&amp;emsp;
                      &lt;/label&gt;
                  &lt;/div&gt;
                  &lt;select id="mySelect" name="" class="form-control-sm"&gt;
                      &lt;option value="0"&gt;0&lt;/option&gt;
                      &lt;option value="1"&gt;1&lt;/option&gt;
                      &lt;option value="2"&gt;2&lt;/option&gt;
                      &lt;option value="3"&gt;3&lt;/option&gt;
                      &lt;option value="4"&gt;4&lt;/option&gt;
                      &lt;option value="5"&gt;5&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
  
  
              &lt;!-- Checkboxes for extra Items for Purchase (Desktop) --&gt;
              &lt;div id="chkYesText1" class="form-group"&gt;
                  &lt;label class=" font-weight-bold" for="checkboxes"&gt;Extra Items for Purchase
                      (Desktop)&lt;/label&gt;
                  &lt;div&gt;
                      &lt;div class="extraItemsDesktop"&gt;
                          &lt;label for="checkboxes-0"&gt;
                              &lt;input type="checkbox" name="wirelessCard" id="wirelessCard" value="wirelessCard"&gt;
                              Wireless Card - $30.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsDesktop"&gt;
                          &lt;label for="checkboxes-1"&gt;
                              &lt;input type="checkbox" name="extraMemory" id="extraMemory" value="extraMemory"&gt;
                              Extra Memory (2GB) - $50.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsDesktop"&gt;
                          &lt;label for="checkboxes-2"&gt;
                              &lt;input type="checkbox" name="speakers" id="speakers" value="speakers"&gt;
                              Speakers - $30.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsDesktop"&gt;
                          &lt;label for="checkboxes-3"&gt;
                              &lt;input type="checkbox" name="surgeProtectors" id="surgeProtectors" value="surgeProtectors"&gt;
                              Surge Protectors - $5.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsDesktop"&gt;
                          &lt;label for="checkboxes-4"&gt;
                              &lt;input type="checkbox" name="flashDrive" id="flashDrive" value="flashDrive"&gt;
                              Flash Drive - $30.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsDesktop"&gt;
                          &lt;label for="checkboxes-5"&gt;
                              &lt;input type="checkbox" name="addSSD" id="addSSD" value="addSSD"&gt;
                              Add SSD (Solid State Drive) - $30.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
              &lt;!-- Checkboxes for extra Items for Purchase (Laptop) --&gt;
              &lt;div id="chkYesText2" class="form-group"&gt;
                  &lt;label class="font-weight-bold" for="checkboxes"&gt;Extra Items for Purchase
                      (Laptop)&lt;/label&gt;
                  &lt;div&gt;
                      &lt;div class="extraItemsLaptop"&gt;
                          &lt;label for="checkboxes-0"&gt;
                              &lt;input type="checkbox" name="wirelessCardLap" id="wirelessCardLap" value="wirelessCardLap"&gt;
                              Surge Protectors - $5.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsLaptop"&gt;
                          &lt;label for="checkboxes-1"&gt;
                              &lt;input type="checkbox" name="flashDriveLap" id="flashDriveLap" value="flashDriveLap"&gt;
                              Flash Drive - $30.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsLaptop"&gt;
                          &lt;label for="checkboxes-2"&gt;
                              &lt;input type="checkbox" name="addSSDLap" id="addSSDLap" value="addSSDLap"&gt;
                              Add SSD (Solid State Drive) - $30.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsLaptop"&gt;
                          &lt;label for="checkboxes-3"&gt;
                              &lt;input type="checkbox" name="extraMemoryLap" id="extraMemoryLap" value="extraMemoryLap"&gt;
                              Extra Memory (2GB) - $50.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                      &lt;div class="extraItemsLaptop"&gt;
                          &lt;label for="checkboxes-4"&gt;
                              &lt;input type="checkbox" name="speakers" id="speakers" value="speakers"&gt;
                              Speakers - $30.00
                          &lt;/label&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
  
          &lt;div class="form-group border border-dark rounded py-3 px-5"&gt;
              &lt;h3&gt;Amount Due: &lt;p id="amountDue"&gt;0&lt;/p&gt;
              &lt;/h3&gt;
          &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>